Hello,
When I try to plot a plotly express choropleth map, I get a problem when plotly loads my custom GeoJson (I am pulling this form th UKβs official open data portal (see link in code snippet below)
Here is my code and I have attached the dummy dataset I am using.
The problem is that I see that the data is showing when I hover and only one of the boundaries have been drawn. The rest of the screen seems to have been filled by the values.
import pandas as pd
import plotly
import numpy as np
from urllib.request import urlopen
import json
with urlopen('https://opendata.arcgis.com/datasets/c572ffec290b42768f80e43d31ac53a6_0.geojson') as response:
counties = json.load(response)
df = pd.read_excel('testdata.xlsx',dtype={"cty19cd": str})
df.columns=['CODE','NAME','VALUE']
import plotly.express as px
fig = px.choropleth(df, geojson=counties, locations='CODE', featureidkey="properties.cty19cd", color='VALUE',
color_continuous_scale="Inferno",
scope="europe")
fig.update_geos( fitbounds="locations", visible=True)
fig.write_html('maptest.html',auto_open=True)
I have researched the web about the problem I am having. I found that the problem might be related to the incompatibility of the current GEOJSON standard and the D3 library that pltly uses under the hood, as discussed here.
Has anybody found a way to make plotly work with this uncompatible GeoJSONS?
Thanks!