我的 Choropleth 地圖有這些奇怪的黑點,我不確定它是否缺少數據。我如何擺脫那些黑點?圖片在這里我的 csv:https://drive.google.com/file/d/10FULaQ7f4lfWdPpk4bzwlD9yymGrL14d/view ?usp=sharing我的 GeoJson:https://drive.google.com/file/d/1GZljNjbIXsx55xopN9_DDlOb0Pi9Eclz/view? usp=sharing我在 Jupyter 上運行這個: # CHOROPLETH MAPimport jsonkunnat_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編輯:解決了這個問題。Folium 無法顯示北歐字母 ?、? 或 ?。不得不從我的數據中刪除它們,現在它可以工作了。
1 回答

RISEBY
TA貢獻1856條經驗 獲得超5個贊
意識到我缺少一些城市的數據。發生這種情況是因為這些城市的名稱中包含北歐字符,而 folium 無法顯示它們。通過使用以下代碼將所有北歐字符替換為英文字母(? = A,? = O 等)來修復它:
dictionary={'?':'a','?':'o','?':'A','?':'a'} df.replace(dictionary, regex=True, inplace=True)
還必須在 geojson 文件中手動替換它們。
添加回答
舉報
0/150
提交
取消