# Offline Choropleth world map plot

**URL:** <https://community.plotly.com/t/offline-choropleth-world-map-plot/77243>\
**Category:** 📊 Plotly Python\
**Created:** [July 28, 2023, 7:49am UTC](https://community.plotly.com/t/offline-choropleth-world-map-plot/77243 "2023-07-28T07:49:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kbernhard](https://avatars.discourse-cdn.com/v4/letter/k/b5e925/32.png) [@Kbernhard](https://community.plotly.com/u/Kbernhard)\
**Post date:** [July 28, 2023, 7:49am UTC](https://community.plotly.com/t/offline-choropleth-world-map-plot/77243/1 "2023-07-28T07:49:51Z")

</div>

I am trying to generate a world map with data in plotly as an html file, which should offline usable.

The problem is that plotly wants to use [https://cdn.plot.ly/world\_110m.json](https://cdn.plot.ly/world_110m.json), is there a way to give it to plotly locally. Like building it into the html file. (Internet while compiling is O.K. afterwards it should be able to run without)

To demonstrate my Problem, I have copied the example from here [Choropleth maps in Python](https://plotly.com/python/choropleth-maps/) and it looks like this:

```auto
import plotly.graph_objects as go
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')

fig = go.Figure(data=go.Choropleth(
    locations = df['CODE'],
    z = df['GDP (BILLIONS)'],
    text = df['COUNTRY'],
    colorscale = 'Blues',
    autocolorscale=False,
    reversescale=True,
    marker_line_color='darkgray',
    marker_line_width=0.5,
    colorbar_tickprefix = '$',
    colorbar_title = 'GDP<br>Billions US$',
))

fig.update_layout(
    title_text='2014 Global GDP',
    geo=dict(
        showframe=False,
        showcoastlines=False,
        projection_type='equirectangular',
    ),
    annotations = [dict(
        x=0.55,
        y=0.1,
        xref='paper',
        yref='paper',
        text='Source: <a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">\
            CIA World Factbook</a>',
        showarrow = False
    )]
)
fig.write_html("file.html")

```

 ![Whit](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/0/4/0492cf50d507f4d1a6f468c0a0b567bc176c6b69.png)

When I try to open it without internet it looks like this(write it to html)

But adding `fig.write_html("file.html",config={'topojsonURL':'./world_110m.json'})`  
(the files are in the same dir, and replacing it with the files URL [https://cdn.plot.ly/world\_110m.json](https://cdn.plot.ly/world_110m.json) also stops it from displaying while in internet)

Doesn’t help either (is also stops working with internet)

If you try it out, don’t forget to use a private window to simulate a different browser

---

<div class="post-metadata">

**Author:** ![WolVes](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/wolves/32/2545_2.png) [@WolVes](https://community.plotly.com/u/WolVes)\
**Post date:** [May 24, 2024, 8:16pm UTC](https://community.plotly.com/t/offline-choropleth-world-map-plot/77243/2 "2024-05-24T20:16:54Z")

</div>

I am running into the same issue. Has anyone found a solution to this?

---

<div class="post-metadata">

**Author:** ![davidharris](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@davidharris](https://community.plotly.com/u/davidharris)\
**Post date:** [May 26, 2024, 7:33am UTC](https://community.plotly.com/t/offline-choropleth-world-map-plot/77243/3 "2024-05-26T07:33:31Z")

</div>

This seems peculiarly difficult. If you do the following, it looks like a step in the right direction, in that it _tries_ to read the geojson file locally, but then hits a `Cross-Origin Request Blocked` error (visible in browser tools) that I don’t know how to bypass:

- Download [https://cdn.plot.ly/world\_110m.json](https://cdn.plot.ly/world_110m.json) to subfolder _assets_
- Add this option to write\_html:

```python
fig.write_html("worldmap.html", config={"topojsonURL":"assets/"})

```

I’m drawing on this post, which gives an alternative of editing _plotly.min.js_ and also gives an alternative solution if using Dash

> [@Loading geo assets offline \[Solved\]](https://community.plotly.com/t/loading-geo-assets-offline-solved/11869):
>
> I am running a Dash server offline and [maps](https://plot.ly/python/scatter-plots-on-maps/) do not load. I can confirm that any map Graph runs if I have an internet connection but it doesn’t render if there is no internet connection (assuming this hasn’t been cached). Specifically, Plotly is looking for assets like [https://cdn.plot.ly/usa\_110m.json](https://cdn.plot.ly/usa_110m.json) to render with. Is there a method to render this locally and offline?
