访问GeoJSON字段的问题

问题描述 投票:0回答:2

[当我尝试添加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],
...

我认为我访问语法可能完全错误,但是我能想到的每种选择都产生相同的结果。

python geojson folium
2个回答
0
投票

尝试一下:

choropleth.geojson.add_child(folium.features.GeoJsonTooltip(fields=['features.properties.NTAName'], labels=False)

0
投票

结果,我必须完全忽略属性的名称,而忽略所有层次结构。这很奇怪。

choropleth.geojson.add_child(folium.features.GeoJsonTooltip(fields=['NTAName'], labels=False))
© www.soinside.com 2019 - 2024. All rights reserved.