[当我尝试添加GeoJson工具提示时:
choropleth.geojson.add_child(folium.features.GeoJsonTooltip(fields=['feature.properties.NTAName'], labels=False))
并获得断言错误:
AssertionError:字段feature.properties.NTAName在数据中不可用。从以下选项中进行选择:(“ BoroCode”,“ BoroName”,“ CountyFIPS”,“ NTACode”,“ NTAName”,“ Shape_Leng”,“ Shape_Area”)。
有问题的JSON看起来像这样:
{'type': 'FeatureCollection',
'crs': {'type': 'name',
'properties': {'name': 'urn:ogc:def:crs:OGC:1.3:CRS84'}},
'features': [{'type': 'Feature',
'properties': {'BoroCode': 3,
'BoroName': 'Brooklyn',
'CountyFIPS': '047',
'NTACode': 'BK43',
'NTAName': 'Midwood',
'Shape_Leng': 27996.5910663,
'Shape_Area': 35799638.2503},
'geometry': {'type': 'Polygon',
'coordinates': [[[-73.94732672160579, 40.62916656720943],
...
我认为我访问语法可能完全错误,但是我能想到的每种选择都产生相同的结果。
尝试一下:
choropleth.geojson.add_child(folium.features.GeoJsonTooltip(fields=['features.properties.NTAName'], labels=False)
结果,我必须完全忽略属性的名称,而忽略所有层次结构。这很奇怪。
choropleth.geojson.add_child(folium.features.GeoJsonTooltip(fields=['NTAName'], labels=False))