Prevent replotting

I have a very large choropleth plot similar to something like this but with custom coordinates

I want to plot additional data through scattergeo at 1 second interval on top of the choropleth base. The scattergeo plots fine on its own, but because the choropleth plot takes over 1 second to plot, the entire graph breaks. Is there a way to “preplot” the choropleth data where I don’t replot every time? I do not need to interact with the choropleth in any way.

In dash-leaflet you can use different layers (objects) and then just update each layer (object) independently. Maybe the same principle can be used here?

It could, I don’t think there is a built in functionality for it. The closest I could find is something like this but there was no solution

Here is a small example on how you can do it in Dash leaflet,

import dash_html_components as html
import dash_core_components as dcc
import dash_leaflet as dl
from dash import Dash
from dash.dependencies import Output, Input

app = Dash(update_title=None)
app.layout = html.Div([
    dl.Map(center=[39, -98], zoom=4, children=[
        dl.TileLayer(),
        dl.Marker(id="marker", position=[25, -100]),
        dl.GeoJSON(url="/assets/us-states.pbf", format="geobuf")
    ], style={'width': '100%', 'height': '50vh', 'margin': "auto", "display": "block"}, id="map"),
    dcc.Interval(id="trigger", interval=25)
])
# Use a callback to move the marker.
app.clientside_callback("function(i){return [25+i*0.2%25, -100];}", Output("marker", "position"),
                        Input("trigger", "n_intervals"), prevent_initial_call=True)

if __name__ == '__main__':
    app.run_server()

Peek 2021-09-04 13-46

1 Like