How to add custom inset maps
In Datawrapper locator maps, you can add an inset map in step 2: Design map. You can either choose a globe or select from a range of pre-defined inset maps.
But there are cases when you might need a custom inset map. For example
- to show an inset map of two countries/states, if a location is close to the border
- if an inset map of the whole state/country/continent is too big, but the next available sub-region is too detailed to be helpful
- when a location is on an island with two countries (e.g., Ireland/Northern Ireland), and you want to show the whole country.
In this article, we show you how to add a custom GeoJSON as your inset map:
1
First, you need a GeoJSON with the region that should become your inset map. To find a GeoJSON of your area, you can use a tool like
geojson-maps.ash.ms, or simply search for it on the web.
We want a GeoJSON with all US states, so we search for "US states GeoJSON". The second search result leads us to a Github page:
https://github.com/PublicaMundi/MappingAPI/blob/master/data/geojson/us-states.json – perfect:
But that already shows us a map. To get the actual GeoJSON, we need to click on "Raw" in the top right. This will lead us to the raw GeoJSON:
https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json
We can now save this "text" to our Downloads folder by pressing Cmd+S:
Great! We got the GeoJSON on our computer. But it shows
all US states, not the ones we need. Here's what we need to do next:
2
In the second step, we
edit our GeoJSON. We can use the online tool
mapshaper.org to do so:
After dragging your downloaded GeoJSON in there, we click
Import, and voila, it shows us the GeoJSON:
Now we can either
clip our map or
select the states we want to show.
Here's how to clip: We click on the little mouse pointer in the sidebar, then on the
shift-drag box tool. Now we hold Shift while dragging a box around the region we want to keep. Then we select
Clip – and now we got a clipped GeoJSON.
Selecting regions in our GeoJSON works similarly: Again, we click on the little mouse pointer in the sidebar, but now we choose
Select features. Now we simply click on all the regions we want to keep, and then choose
Keep:
3
Now we download our edited GeoJSON from Mapshaper. To do so, click on
Export in the top right and then on
GeoJSON. Confirm with a click on
Export in the pop-up.
4
Almost there! Now we want to import the GeoJSON to our Datawrapper locator map. To do so, we simply drag the new edited GeoJSON on the
Upload GeoJSON button, or click on it and select the GeoJSON from the location on our computer:
That's it! If you still have some questions, don't hesitate to get in touch with uats
support@datawrapper.de. We're looking forward to helping you.