I am trying to create a cloropleth map of provinces in the Netherlands, using a JSON file I download through an API (https://geodata.nationaalgeoregister.nl/).
The following code just gives me an empty map. I’ve been going through the documentation and some threads on here, but I cant seem to work it out. Does anyone know what the problem is?
After I get the map to draw I also want to fill it data from a dataframe, but first things first.
import urllib.request
import json
import plotly.express as px
geo_url = 'https://geodata.nationaalgeoregister.nl/cbsgebiedsindelingen/wfs?request=GetFeature&service=WFS&version=2.0.0&typeName=cbs_provincie_2017_gegeneraliseerd&outputFormat=json'
def read_geojson(url):
with urllib.request.urlopen(url) as url:
jdata = json.loads(url.read().decode())
return jdata
jdata = read_geojson(geo_url) # keys are: dict_keys(['type', 'id', 'geometry', 'geometry_name', 'properties'])
fig = px.choropleth(geojson=jdata)
fig.show()