【发布时间】:2019-07-18 05:15:56
【问题描述】:
使用 GeoJson 时出现 AttributeError。我已阅读文档,但找不到任何线索。
import folium
from folium import GeoJson
LA_COORDINATES = (34.0522, -118.2437)
zip_geo = r'zip-code-tabulation-areas-2012.geojson'
df_zip.to_json('ticket_agg.json')
df_zip.columns = ['Zipcode','Ticket_Count']
# creation of the choropleth
map1 = folium.Map(location=LA_COORDINATES, zoom_start=12)
map1.GeoJson(geo_path = zip_geo,
data_out = 'ticket_agg.json',
data = df_zip,
columns = ['Zipcode','Ticket_Count'],
key_on = 'feature.properties.external_id',
fill_color = 'YlOrRd',
fill_opacity = 0.7,
line_opacity = 0.2,
legend_name = 'Tickets per zip')
display(map1)
错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-61-f15e83f4678b> in <module>
19 # creation of the choropleth
20 map1 = folium.Map(location=LA_COORDINATES, zoom_start=12)
---> 21 map1.GeoJson(geo_path = zip_geo,
22 data_out = 'ticket_agg.json',
23 data = df_zip,
AttributeError: 'Map' object has no attribute 'GeoJson'
这是我正在使用的 geo_json 文件的链接:http://s3-us-west-2.amazonaws.com/boundaries.latimes.com/archive/1.0/boundary-set/zip-code-tabulation-areas-2012.geojson
任何建议将不胜感激!
【问题讨论】: