Hi,
I am trying to plot Covid-19 data on a plotly chorolepth map but the map does not show anything but an empty ploy. The geosjon file is as follows:
https://www.webuildinternet.com/articles/2015-07-19-geojson-data-of-the-netherlands/townships.geojson
And a Dataframe example looks as follows:
Gemeente ... Overleden_inc100000
0 's-Gravenhage (gemeente) ... 0,5
Below the code I used:
import pandas as pd
from urllib.request import urlopen, Request
import json
import plotly.express as px
#https://www.cbs.nl/nl-nl/onze-diensten/open-data/statline-als-open-data/cartografie
#https://chart-studio.plotly.com/~empet/15238/tips-to-extract-data-from-a-geojson-di/#/
#geodata_url1 = 'https://geodata.nationaalgeoregister.nl/cbsgebiedsindelingen/wfs?request=GetFeature&service=WFS&version=2.0.0&typeName=cbs_gemeente_2017_gegeneraliseerd&outputFormat=json'
geodata_url2 = 'https://www.webuildinternet.com/articles/2015-07-19-geojson-data-of-the-netherlands/townships.geojson'
req = Request(geodata_url2, headers={'User-Agent': 'Mozilla/5.0'})
with urlopen(req) as response:
dutch_town = json.load(response)
df = pd.read_csv('C:/Users/Dante/Desktop/Covid-19/Covid_Data/Reported COVID-19 patients - Per county from 1-Jul-2020 until 14-Jul-2020.csv', delimiter=';')
#print(dutch_town)
fig = px.choropleth(df, geojson=dutch_town,
locations= 'Gemeente', color= "Totaal_Absoluut",
color_continuous_scale="Viridis",
range_color=(df["Totaal_Absoluut"].min(), df["Totaal_Absoluut"].max()),
labels={"Totaal_Absoluut": 'Overleden'}
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()