Iāve problem similar to another problem submitted to the forum and solved a few months ago and therefore Iām referring to previous post and to the data used in it.
In the reply to this post
Emmanuelle showed how to use geojson and featureidkey attributes in a go.Choropleth trace, as in following code
import json
from urllib.request import urlopen
import pandas as pd
import numpy as np
import plotly.graph_objects as go
df = pd.read_csv(āhttps://raw.githubusercontent.com/FBosler/covid19-dash-app/master/functions/data.csvā)
counties = json.load(open(ācounties.jsonā))
URL = āhttps://raw.githubusercontent.com/FBosler/covid19-dash-app/master/functions/counties.jsonā
with urlopen(URL) as response:
counties = json.load(response)
trace = go.Choropleth(
geojson=counties,
z=np.log10(df[āinfectedā]),
locations=df[āLandkreisā],
featureidkey=āproperties.NAME_3ā)
fig = go.Figure(data=trace)
fig.update_geos(fitbounds=ālocationsā)
fig.show()
Iām trying to create a go.Scattergeo plot with geojson and featureidkey attributes (see following code), but the output is not the expected one. The markers are shown and the map defined in geojosn file is not shown. What is missing in my example?
Next step will be to animate the scatter plot, with the size of the markers changing in each frame, but by now Iām trying to draw a static plot.
Thanks in advance for your help
Mauro
trace = go.Scattergeo(
marker=dict(size=df[āinfectedā],
sizemode=āareaā),
geojson=counties,
locations=df[āLandkreisā],
featureidkey=āproperties.NAME_3ā)
fig = go.Figure(data=trace)
fig.update_geos(fitbounds=ālocationsā)
fig.show()