0

I am building a small app in Dash where I want to plot data on a map. I am loading a geojson file that holds my countries regions delimitation using geopandas. I made a test dataframe containing random values for some regions. I am ploting eveything using plotly choropleth_mapbox. It works but is very slow. When I decide to put data for all regions it can take up to 20 minutes. Would you have any idea how I can fasten it ? Or would you advise using other libraries than geopandas and plotly ?

code:

import geopandas
import plotly.express as px

geojson = geopandas.read_file('static/Mapping/Departements.geojson')
df['code'] = [59, 75, 24]
df['value'] = [150, 10, 256]

fig = px.choropleth_mapbox(df, geojson=geojson, locations='code', color='value',
                            color_continuous_scale="Viridis",
                            range_color=(0, 12),
                            mapbox_style="carto-positron",
                            zoom=4, center = {"lat": 48.856614, "lon": 2.3522219},
                            opacity=0.5,
                            labels={'Value':'Test values'}
                          ) 
Victor Gl
  • 81
  • 1
  • 8
  • 1
    Performance may be affected depending on the number of geojson records used. How many records are actually used? As a countermeasure, changing the area to be painted on the map from county to state would be a consideration. Can you present the geojson being used? – r-beginners Dec 29 '22 at 03:07

0 Answers0