How to merge regions with Mapshaper

Sometimes, you might want one large region that consists of different sub-regions, but your GeoJSON has all the regions listed separately and they all appear with their own popup. This help doc will walk you through merging those regions using a free online tool called Mapshaper.

In this help doc, we're going to be merging regions to create the regions displayed above.

    1
    Upload your GeoJSON file to Mapshaper. https://geojson-maps.ash.ms/ is a great resource to get public domain GeoJSON files from Natural Earth. 

    2
    Use the "select regions" tool to select the regions you would like to merge into one. We're looking to merge the USA and Canada into "North America" in this example. Once selected, choose "Split" from the options that appear in the upper area of the editor.

    3
    Once you've split out your regions, they will appear greyed out. If you click on the dropdown where the name of your GeoJSON is displaying, you'll see they've been moved to a separate layer. Click into that layer.

    4
    Once you're in your new layer (the regions you want to merge should display with a black outline), it's time to merge. To do this, open the console in Mapbox and run the command -dissolve. This will merge adjacent polygons by erasing shared boundaries.

    5
    Go back to the main layer and repeat, splitting out and then dissolving groups of polygons you'd like to appear as one region in your map. In our case, we end up with five different layers, in which we've all ran the -dissolve command. 

    You can check if the merging has worked by hovering over your regions with the selection tool. If they've been merged correctly, the whole block of split out regions will appear outlined in black.

    6
    Now it's time to merge the layers back together. To do this, open the console and run the command merge-layers target=region1,region2 force. (Replace region1 and region2 with the names of your regions.) Keep merging the split out layers back into the master layer one by one, until you only have one layer again.
    7
    Once you have one layer, you can export that as a GeoJSON file and import it to Flourish.