访问GeoJSON字段的问题

2024-09-28 17:02:31 发布

您现在位置:Python中文网/ 问答频道 /正文

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

我想我可能把访问文件的语法完全弄错了,但我所能想到的每一种选择都产生了相同的结果


Tags: namegeojsontypeareapropertiesfeaturefeaturesshape