I tried to follow the tutorial on https://plotly.com/r/mapbox-county-choropleth/, but couldn't work out how to use it with another geojson about covid-19 data from the german government.
library(plotly)
library(rjson)
url <- 'https://raw.githubusercontent.com/Johannes96/Coropleth/main/RKI_Corona_Bundeslaender_2.geojson'
geojson <- rjson::fromJSON(file=url)
url2<- "https://raw.githubusercontent.com/Johannes96/Coropleth/main/RKI_Corona_Bundeslaender.csv"
df <- read.csv(url2)
g <- list(
fitbounds = "locations",
visible = FALSE
)
fig <- plot_ly()
fig <- fig %>% add_trace(
type="choroplethmapbox",
geojson=geojson,
locations=df$ObjectId,
z=df$AnzahlFall,
colorscale="Viridis",
featureidkey="properties.OBJECTID_1"
)
fig <- fig %>% colorbar(title = "covid-19 cases germany")
fig <- fig %>% layout(
mapbox=list(
style="carto-positron",
zoom =5,
center=list(lon=9.7, lat=50))
)
fig
The problem is that it doesn't plot the shapes of the geojson file. Tried to find a solution since several hours but it just won't work. Any help or guideline would be appreciated.