【发布时间】:2022-01-22 11:20:26
【问题描述】:
我无法获取一些空气污染数据以在使用叶绿素的叶绿素地图中显示不同的颜色。请让我知道我的代码可能在哪里引发错误。我认为这是 key_on 参数,但需要帮助。
这就是我的地图的结果。 enter image description here
我希望空气污染数据的平均浓度显示在地图上,但地图仍然是灰色的。
这是我使用的文件:
-
Geojson 文件 - 使用本网站右上角的“下载 zip”https://gist.github.com/miguelpaz/edbc79fc55447ae736704654b3b2ef90#file-uhf42-geojson
-
数据文件 - 从这里导出的数据https://a816-dohbesp.nyc.gov/IndicatorPublic/VisualizationData.aspx?id=2023,719b87,122,Summarize
这是我的代码:
将 geopandas 导入为 gpd 进口叶
#clean pollution data pm_df1 = pd.read_csv('/work/Fine Particulate Matter (PM2.5).csv',header = 5, usecols = ['GeoTypeName', 'Borough','Geography', 'Geography ID','Mean (mcg per cubic meter)'], nrows = 140) #limit dataframe to rows with neighborhood (UHF 42) that matches geojson file pm_df2 = pm_df1[(pm_df1['GeoTypeName'] == 'Neighborhood (UHF 42)')] pm_df2 #clean geojson file uhf_df2 = gpd.read_file('/work/uhf42.geojson', driver='GeoJSON') uhf_df2.head() #drop row 1 that has no geography uhf_df3 = uhf_df2.iloc[1:] uhf_df3.head() ## create a map pm_testmap = folium.Map(location=[40.65639,-73.97379], tiles = "cartodbpositron", zoom_start=10) # generate choropleth map pm_testmap.choropleth( geo_data=uhf_df3, data=pm_df2, columns=['Geography', 'Mean (mcg per cubic meter)'], key_on='feature.properties.uhf_neigh', #think this is where I mess up. fill_color='BuPu', fill_opacity=0.2, line_opacity=0.7, legend_name='Average dust concentration', smooth_factor=0) # display map pm_testmap
【问题讨论】: