Skip to content

How to reduce GeoJSON shapefile size using mapshaper.org, with some tweaks for plotly choropleths and D3.js

Notifications You must be signed in to change notification settings

yasserius/mapshaper_geojson_simplify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to reduce GeoJSON file size with mapshaper.org

GeoJSON and shapfiles can be a few hundred megabytes, and that becomes a problem when you are trying to make interactive online maps where the webpage size should be small.

https://mapshaper.org/ to the rescue! No installation whatever, all inside a browser, yet super fast.

But there are some problems still if you use the converted files with plotly for making choropleths. Hence this guide:

Step 1: Import file

Go to https://mapshaper.org/ and import your GeoJSON file.

Step 2

Make sure "detect line intersection" is checked.

Step 3

If you map loads correctly, click "Simplify".

Step 4

Tick "prevent shape removal", use "Visvalingam / weigthed area" if you don't have other preferences and apply.

Step 5

Move the slider to any percentage. If your initial filesize is 100 MB and you slide to 1%, then output file will be 1% of 100 MB. Also click "Repair" after sliding.

Step 6

Now click export.

Step 7

Use whatever output format you please, but for compatibility with plotly and D3.js, you should include the output parameter gj2008 to export properly.

And you're done! yay

About

How to reduce GeoJSON shapefile size using mapshaper.org, with some tweaks for plotly choropleths and D3.js

Topics

Resources

Stars

Watchers

Forks