简体   繁体   English

如何去除 Choropleth map 中的黑点

[英]How to get rid of black spots in Choropleth map

My Choropleth map has these weird black spots and i'm not sure if its missing data or not.我的 Choropleth map 有这些奇怪的黑点,我不确定它是否缺少数据。 How do I get rid of those black spots?我如何摆脱这些黑点?

Picture here图片在这里

My csv: https://drive.google.com/file/d/10FULaQ7f4lfWdPpk4bzwlD9yymGrL14d/view?usp=sharing我的 csv: https://drive.google.com/file/d/10FULaQ7f4lfWdPpk4bzwlD9yymGrL14d/view?usp=sharing

My GeoJson: https://drive.google.com/file/d/1GZljNjbIXsx55xopN9_DDlOb0Pi9Eclz/view?usp=sharing我的 GeoJson: https://drive.google.com/file/d/1GZljNjbIXsx55xopN9_DDlOb0Pi9Eclz/view?usp=sharing

I'm running this on Jupyter:我在 Jupyter 上运行它:

    # CHOROPLETH MAP
import json
kunnat_geo = r'kuntarajat.geojson'
with open(kunnat_geo) as kunnat_file:
    kunnat_json = json.load(kunnat_file,encoding='utf8')
type(kunnat_json)

df = pd.read_csv('cleandata.csv')


map = folium.Map(location=[65,26], zoom_start=4, tiles='openstreetmap')
map.choropleth(geo_data=kunnat_geo,
             data=df, # my dataset
             columns=['Kunta', 'data'], 
             key_on='feature.properties.Name',
             fill_color='OrRd', fill_opacity=0.7, line_opacity=0.2,
             legend_name='Mielenterveyden kuntoutuskotien asiakkaat vuonna 2018',
             smooth_factor=0)

marker_cluster = MarkerCluster().add_to(map)
for i in range(0,len(coords)):

    folium.Marker([coords.iloc[i]['lat'], coords.iloc[i]['lng']], popup=coords.iloc[i]['data'],tooltip='Mielenterveyden kuntoutuskotien asiakkaat vuonna 2018').add_to(marker_cluster)
coords.head()

map.save('Choropleth.html')
map

Edit: Solved the issue.编辑:解决了这个问题。 Folium isn't able to show nordic letters Ä, Ö or Å. Folium 无法显示北欧字母 Ä、Ö 或 Å。 Had to delete them from my data and now it works.不得不从我的数据中删除它们,现在它可以工作了。

Realized I was missing data in some of the cities.意识到我在一些城市丢失了数据。 This happens because those cities have nordic characters in their name, and folium is not able to show them.发生这种情况是因为这些城市的名称中有北欧字符,而 folium 无法显示它们。 Fixed it by replacing all nordic characters with english letters (Ä = A, Ö = O etc) with following code:通过使用以下代码将所有北欧字符替换为英文字母(Ä = A、Ö = O 等)来修复它:

dictionary={'ä':'a','ö':'o','Ä':'A','å':'a'}
df.replace(dictionary, regex=True, inplace=True)

Also had to replace them manually in the geojson file.还必须在 geojson 文件中手动替换它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM