This is the process for preparing map data to generate cartograms.
First, visit https://gadm.org/download_country_v3.html and select the country. Click on "Shapefile", which will download a zip file. You can also obtain the map from another website. Shapefiles, GeoJSON and TopoJSON are supported by Mapshaper.
Then, visit https://mapshaper.org/ and import the zip file.
Click on the correct layer, which should be gadm36_[country]_1
for a map downloaded from GADM, as seen in the image below:
You will need to know the desired projection for this map. Then, click on console (upper right corner) and type the following command to project the map, replacing [spatial_reference]
with your chosen spatial reference system:
$ -proj +init=EPSG:[spatial_reference]
Check to make sure that the map is projected correctly.
Type the following command to find out the total number of vertices.
$ -simplify 100% stats
The unique coordinate locations tells you the number of vertices. Use the following equation to calculate the percentage required.
[percentage] = 100 * [desired no. of vertices] / [unique coordinate locations]
So, if you would like 50,000 verticies, then the percentage will be 100 * 50,000 / 573,076 ≈ 9 We recommend 50,000 vertices for an optimal balance between time, space and resolution.
Then, type the following command to execute the simplification, replacing [percentage]
with the required percentage:
$ -simplify [percentage]% stats
In Mapshaper, export the map using the following command, replacing [country_name]
accordingly.
$ -o format=geojson [country_name].json
Now, continue following the steps here to generate the cartogram: https://github.com/Flow-Based-Cartograms/go_cart#running-the-cartogram-generator