Docs › Guides › Simplification

Simplification

Simplification reduces the number of vertices in polylines and polygon boundaries while preserving as much of their shape as possible. It is Mapshaper's original feature, and the workhorse for reducing large, detailed datasets to a size practical for web maps.

Choosing a method

Mapshaper offers three simplification methods, selectable as flags to -simplify:

  • dp — Douglas-Peucker (also known as Ramer–Douglas–Peucker). Guarantees that simplified lines stay within a fixed distance of the original. Good for stripping excess vertices to reduce file size, but tends to grow visible spikes at high simplification.
  • visvalingam — The Visvalingam algorithm. Iteratively removes the point that forms the smallest triangle with its two neighbors.
  • weighted_visvalingam (Mapshaper's default) — Visvalingam's effective-area algorithm with a custom weighting that underweights points at sharp angles, so they are removed earlier than in standard Visvalingam. The result is visibly smoother lines and fewer jagged spikes at high simplification.

Weighted Visvalingam is the default because it has proven to be versatile and effective at reducing detail in highly detailed source data. This method can be effective at generalizing very detailed source files, but be careful that it doesn't remove long, thin geographic features that you want to keep.You can control the amount of weighting used by Weighted Visvalingam with the weighting= option (default is 0.7).

If you are only interested in minimizing file size, Douglas-Peucker is generally the better choice.

Figures

Natural Earth 10m coastlines, simplified with modified Visvalingam at 5% point retention. image

Same file using Douglas-Peucker, also 5% simplification. image

Zoomed-in view of Norwegian coastline at 5% simplification; left: weighted Visvalingam, right: Douglas-Peucker. image

Simplification amount

On the command line, there are three ways to specify the amount of simplification to apply: percentage, interval, and resolution.

Percentage is the default (you don't need to type percentage=). It gives the percentage of removable vertices to retain, so lower numbers = more simplification.

mapshaper provinces.geojson -simplify 20% \
  -o provinces_simplified.geojson

The interval option takes a distance threshold. With Douglas-Peucker simplification (see below), this is the maximum deviation of the simplified line from the original. With Visvalingam-based methods, interval= describes the approximate size of the smallest details in the simplified output.

mapshaper provinces.geojson -simplify interval=500m \
  -o provinces_simplified.geojson

The resolution= option lets you specify the intended display size of your map in SVG units (equivalent to CSS pixels). A larger value retains more detail, since Mapshaper estimates the display size using the full extent of your data. Be careful with this option if your final map will show a smaller geographic area, as the paths may be over-simplified.

mapshaper provinces.geojson -simplify resolution=800 \
  -o provinces_simplified.geojson

See the -simplify reference for the full set of options.

Avoiding shape removal

At high simplification, small polygons can disappear entirely. Pass keep-shapes to -simplify (or tick prevent shape removal in the web UI's Simplify panel) to retain at least one ring per multipart feature, regardless of how aggressive the simplification is.

mapshaper provinces.shp -simplify 5% keep-shapes -o provinces.geojson

Spherical vs planar geometry

By default, Mapshaper simplifies lat/long coordinates on the surface of a sphere, using 3D geometry. This applies a consistent amount of simplification across the whole globe, including near the poles. If your data is in a projected coordinate system, simplification uses 2D planar geometry.

Avoiding self-intersections

Heavy simplification can pull adjacent polygon edges across each other, producing self-intersections. The -simplify command detects and tries to remove intersections automatically by rolling back simplification where the intersections occur. In the web UI, you can enable "detect line intersections" on the Display panel to show intersections as red dots. In this mode, you will see a button for repairing intersections caused by simplification.

The -clean command will also remove intersections:

mapshaper provinces.shp -simplify 5% -clean -o provinces.geojson

Simplifying multiple layers consistently

When you import multiple layers using -i combine-files, Mapshaper builds a shared topology. This means that boundaries shared between layers — for example, aligned state and county polygon borders — are simplified identically across both. Without this, the layers would diverge during simplification, creating visible gaps and overlaps where they should align.

mapshaper -i states.shp counties.shp combine-files \
  -simplify 10% \
  -o out/

The web app does not combine files automatically when you import multiple layers. To get the shared-topology behavior in the web app, tick with advanced options in the import dialog and add combine-files to the options field.