mapshaper 0.6.121 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +5 -3
  2. package/mapshaper.js +1342 -275
  3. package/package.json +5 -2
  4. package/www/assets/jetbrains-mono-regular.woff2 +0 -0
  5. package/www/assets/static-page.css +179 -0
  6. package/www/docs/_assets/cmd-search.js +213 -0
  7. package/www/docs/_assets/docs.css +712 -0
  8. package/www/docs/_assets/docs.js +75 -0
  9. package/www/docs/_assets/highlight.css +10 -0
  10. package/www/docs/essentials/command-line.html +127 -0
  11. package/www/docs/essentials/command-line.html.md +112 -0
  12. package/www/docs/essentials/web-app.html +138 -0
  13. package/www/docs/essentials/web-app.html.md +106 -0
  14. package/www/docs/examples/basics.html +276 -0
  15. package/www/docs/examples/basics.html.md +371 -0
  16. package/www/docs/examples/data/Makefile +31 -0
  17. package/www/docs/examples/data/globe.msx +0 -0
  18. package/www/docs/examples/data/globe.svg +616 -0
  19. package/www/docs/examples/data/globe.txt +21 -0
  20. package/www/docs/examples/data/globe.zip +0 -0
  21. package/www/docs/examples/data/ne_50m_admin_0_countries.geojson +1 -0
  22. package/www/docs/examples/data/ne_50m_admin_1_states_provinces_lakes.geojson +1 -0
  23. package/www/docs/examples/data/us-states.msx +0 -0
  24. package/www/docs/examples/data/us-states.svg +56 -0
  25. package/www/docs/examples/data/us-states.txt +6 -0
  26. package/www/docs/examples/data/us-states.zip +0 -0
  27. package/www/docs/examples/globe.html +108 -0
  28. package/www/docs/examples/globe.html.md +64 -0
  29. package/www/docs/examples/us-states.html +88 -0
  30. package/www/docs/examples/us-states.html.md +44 -0
  31. package/www/docs/formats/csv.html +127 -0
  32. package/www/docs/formats/csv.html.md +97 -0
  33. package/www/docs/formats/dbf.html +87 -0
  34. package/www/docs/formats/dbf.html.md +39 -0
  35. package/www/docs/formats/flatgeobuf.html +86 -0
  36. package/www/docs/formats/flatgeobuf.html.md +42 -0
  37. package/www/docs/formats/geojson.html +107 -0
  38. package/www/docs/formats/geojson.html.md +65 -0
  39. package/www/docs/formats/geopackage.html +87 -0
  40. package/www/docs/formats/geopackage.html.md +42 -0
  41. package/www/docs/formats/json.html +83 -0
  42. package/www/docs/formats/json.html.md +35 -0
  43. package/www/docs/formats/kml.html +82 -0
  44. package/www/docs/formats/kml.html.md +39 -0
  45. package/www/docs/formats/overview.html +192 -0
  46. package/www/docs/formats/overview.html.md +35 -0
  47. package/www/docs/formats/shapefile.html +123 -0
  48. package/www/docs/formats/shapefile.html.md +84 -0
  49. package/www/docs/formats/snapshot.html +87 -0
  50. package/www/docs/formats/snapshot.html.md +39 -0
  51. package/www/docs/formats/svg.html +99 -0
  52. package/www/docs/formats/svg.html.md +51 -0
  53. package/www/docs/formats/topojson.html +102 -0
  54. package/www/docs/formats/topojson.html.md +54 -0
  55. package/www/docs/gallery/index.html +80 -0
  56. package/www/docs/gallery/index.html.md +29 -0
  57. package/www/docs/guides/combining-layers.html +105 -0
  58. package/www/docs/guides/combining-layers.html.md +81 -0
  59. package/www/docs/guides/expressions.html +600 -0
  60. package/www/docs/guides/expressions.html.md +376 -0
  61. package/www/docs/guides/programmatic.html +117 -0
  62. package/www/docs/guides/programmatic.html.md +91 -0
  63. package/www/docs/guides/projections.html +158 -0
  64. package/www/docs/guides/projections.html.md +118 -0
  65. package/www/docs/guides/simplification.html +110 -0
  66. package/www/docs/guides/simplification.html.md +94 -0
  67. package/www/docs/guides/topology.html +90 -0
  68. package/www/docs/guides/topology.html.md +63 -0
  69. package/www/docs/images/simplification-detail.png +0 -0
  70. package/www/docs/images/simplification-dp.png +0 -0
  71. package/www/docs/images/simplification-mod2.png +0 -0
  72. package/www/docs/index.html +101 -0
  73. package/www/docs/index.html.md +59 -0
  74. package/www/docs/reference.html +1302 -0
  75. package/www/docs/reference.html.md +1817 -0
  76. package/www/docs/whats-new.html +76 -0
  77. package/www/docs/whats-new.html.md +53 -0
  78. package/www/index.html +30 -3
  79. package/www/llms-full.txt +4040 -0
  80. package/www/llms.txt +55 -0
  81. package/www/mapshaper-gui.js +7 -1
  82. package/www/mapshaper.js +1342 -275
  83. package/www/page.css +1 -1
  84. package/www/privacy.html +1 -112
  85. package/www/sponsor.html +4 -164
  86. package/www/terms.html +1 -112
@@ -0,0 +1,158 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Projections &middot; mapshaper docs</title>
7
+ <meta name="description" content="How to reproject geographic data with Mapshaper, including CRS notation, built-in aliases, and the albersusa composite projection.">
8
+ <link rel="icon" type="image/png" href="/images/icon.png">
9
+ <link rel="stylesheet" href="/docs/_assets/highlight.css">
10
+ <link rel="stylesheet" href="/docs/_assets/docs.css">
11
+ </head>
12
+ <body class="">
13
+
14
+ <header class="page-header">
15
+ <a href="/" class="mapshaper-logo">map<span class="logo-highlight">shaper</span></a>
16
+ <span class="header-section-label">Docs</span>
17
+ <nav class="header-nav">
18
+ <a href="/">Web app</a>
19
+ <a href="https://github.com/mbloch/mapshaper">GitHub</a>
20
+ <a href="/sponsor.html" class="sponsor-link"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg> Become a sponsor</a>
21
+ </nav>
22
+ </header>
23
+
24
+ <div class="docs-layout">
25
+
26
+ <aside class="docs-sidebar">
27
+ <div class="sidebar-inner">
28
+ <nav class="docs-nav"><ul class="top-links"><li><a href="/docs/">Home</a></li><li><a href="/docs/whats-new.html">What&#39;s new</a></li><li><a href="/docs/reference.html">Command reference</a></li><li><a href="/docs/gallery/">Gallery</a></li></ul><h2>Getting started</h2><ul><li><a href="/docs/essentials/command-line.html">The command-line tool</a></li><li><a href="/docs/essentials/web-app.html">The web app</a></li></ul><h2>Guides</h2><ul><li><a href="/docs/guides/simplification.html">Simplification</a></li><li><a href="/docs/guides/expressions.html">JavaScript expressions</a></li><li><a href="/docs/guides/projections.html" class="is-active">Projections</a></li><li><a href="/docs/guides/topology.html">Topology and cleaning</a></li><li><a href="/docs/guides/combining-layers.html">Combining two layers</a></li><li><a href="/docs/guides/programmatic.html">Using Mapshaper from Node.js</a></li></ul><h2>Formats</h2><ul><li><a href="/docs/formats/overview.html">Overview</a></li><li><a href="/docs/formats/shapefile.html">Shapefile</a></li><li><a href="/docs/formats/geojson.html">GeoJSON</a></li><li><a href="/docs/formats/topojson.html">TopoJSON</a></li><li><a href="/docs/formats/geopackage.html">GeoPackage</a></li><li><a href="/docs/formats/flatgeobuf.html">FlatGeobuf</a></li><li><a href="/docs/formats/kml.html">KML / KMZ</a></li><li><a href="/docs/formats/csv.html">CSV / TSV</a></li><li><a href="/docs/formats/dbf.html">DBF</a></li><li><a href="/docs/formats/json.html">JSON records</a></li><li><a href="/docs/formats/svg.html">SVG</a></li><li><a href="/docs/formats/snapshot.html">Mapshaper snapshot</a></li></ul><h2>Examples</h2><ul><li><a href="/docs/examples/basics.html">Basics</a></li><li><a href="/docs/examples/globe.html">Globe</a></li><li><a href="/docs/examples/us-states.html">U.S. state map</a></li></ul></nav>
29
+ </div>
30
+ </aside>
31
+
32
+ <main class="docs-main">
33
+ <article class="docs-article">
34
+ <div class="docs-breadcrumbs"><a href="/docs/">Docs</a> &rsaquo; Guides &rsaquo; Projections</div>
35
+ <h1 id="projections">Projections</h1>
36
+ <p>Mapshaper&#39;s <a href="/docs/reference.html#-proj"><code>-proj</code></a> command reprojects a dataset from one coordinate reference system (CRS) to another, using a JavaScript port of the <a href="https://proj.org/">PROJ</a> coordinate transformation library.</p>
37
+ <p><strong>Examples</strong></p>
38
+ <pre><code class="hljs language-bash"><span class="hljs-comment"># Project a Shapefile to UTM zone 11N using a PROJ string</span>
39
+ mapshaper nevada.shp -proj +proj=utm +zone=11 -o
40
+
41
+ <span class="hljs-comment"># Convert a projected Shapefile to WGS84 — the following are equivalent:</span>
42
+ mapshaper nyc.shp -proj EPSG:4326 -o
43
+ mapshaper nyc.shp -proj wgs84 -o
44
+ mapshaper nyc.shp -proj +proj=longlat +datum=WGS84 -o
45
+
46
+ <span class="hljs-comment"># Composite projection for U.S. maps with Alaska, Hawaii, and Puerto Rico insets</span>
47
+ mapshaper us-states.shp -proj albersusa +PR -o
48
+ </code></pre>
49
+ <h2 id="forms-of-crs-notation">Forms of CRS notation</h2>
50
+ <p><code>-proj</code> accepts a CRS in any of three forms.</p>
51
+ <p><strong>PROJ strings</strong> are sequences of <code>+key=value</code> parameters. They are the lowest-level form and expose the full set of options for each projection. Parameters that have sensible defaults (datum, units, false easting/northing) can usually be omitted.</p>
52
+ <pre><code class="hljs language-bash">mapshaper data.shp -proj +proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96 -o
53
+ </code></pre>
54
+ <p><strong>EPSG codes</strong> are numeric identifiers from the <a href="https://epsg.io/">EPSG registry</a>. Thousands of national and regional coordinate systems have EPSG codes, making them a compact and unambiguous way to specify a CRS.</p>
55
+ <pre><code class="hljs language-bash">mapshaper data.shp -proj EPSG:3857 -o <span class="hljs-comment"># Web Mercator</span>
56
+ mapshaper data.shp -proj EPSG:32611 -o <span class="hljs-comment"># UTM zone 11N (WGS84)</span>
57
+ </code></pre>
58
+ <p><strong>Aliases</strong> are short names for common projections. Run <code>mapshaper -projections</code> to print the full list. The built-in aliases are:</p>
59
+ <table>
60
+ <thead>
61
+ <tr>
62
+ <th>Alias</th>
63
+ <th>Equivalent PROJ string</th>
64
+ </tr>
65
+ </thead>
66
+ <tbody><tr>
67
+ <td><code>wgs84</code></td>
68
+ <td><code>+proj=longlat +datum=WGS84</code></td>
69
+ </tr>
70
+ <tr>
71
+ <td><code>webmercator</code></td>
72
+ <td><code>+proj=merc +a=6378137 +b=6378137</code></td>
73
+ </tr>
74
+ <tr>
75
+ <td><code>robinson</code></td>
76
+ <td><code>+proj=robin +datum=WGS84</code></td>
77
+ </tr>
78
+ <tr>
79
+ <td><code>albersusa</code></td>
80
+ <td><a href="#albersusa">Composite U.S. projection</a> (see below)</td>
81
+ </tr>
82
+ </tbody></table>
83
+ <p>You can also use a bare PROJ projection name (without <code>+proj=</code>) as shorthand when no extra parameters are required:</p>
84
+ <pre><code class="hljs language-bash">mapshaper world.shp -proj robin -o
85
+ </code></pre>
86
+ <h2 id="auto-fitted-parameters">Auto-fitted parameters</h2>
87
+ <p>For some conic and cylindrical projections, you can supply just the projection name and Mapshaper will calculate suitable parameters from the extent of the data. This is useful when you want a locally appropriate projection without looking up specific values.</p>
88
+ <p>For <strong>Lambert Conformal Conic</strong> (<code>lcc</code>) and <strong>Albers Equal Area Conic</strong> (<code>aea</code>), Mapshaper calculates the central meridian (<code>lon_0</code>) and two standard parallels (<code>lat_1</code>, <code>lat_2</code>) using the one-sixth rule applied to the data&#39;s bounding box.</p>
89
+ <p>For <strong>Transverse Mercator</strong> (<code>tmerc</code>, <code>etmerc</code>), it calculates the central meridian and latitude of origin (<code>lon_0</code>, <code>lat_0</code>) from the center of the bounding box.</p>
90
+ <pre><code class="hljs language-bash"><span class="hljs-comment"># Mapshaper fills in lon_0, lat_1, lat_2 based on the data extent</span>
91
+ mapshaper region.geojson -proj lcc -o region_lcc.geojson
92
+
93
+ <span class="hljs-comment"># Equivalent — Mapshaper fills in lon_0 and lat_0</span>
94
+ mapshaper region.geojson -proj tmerc -o region_tmerc.geojson
95
+ </code></pre>
96
+ <p>When Mapshaper auto-fits parameters, it prints the expanded PROJ string so you can see exactly what was applied — for example: <code>Converted &quot;lcc&quot; to &quot;+proj=lcc +lon_0=-95.5 +lat_1=30.17 +lat_2=44.83&quot;</code>. You can copy that string and use it explicitly if you need reproducible output.</p>
97
+ <h2 id="albersusa">albersusa</h2>
98
+ <p><code>albersusa</code> is a Mapshaper-specific composite projection for maps of the United States. It is not part of the PROJ library. It applies Albers Equal Area Conic to the contiguous 48 states, then tiles Alaska (scaled down) and Hawaii as insets in the lower-left corner of the map.</p>
99
+ <pre><code class="hljs language-bash">mapshaper us-states.shp -proj albersusa -o
100
+ </code></pre>
101
+ <p>Two optional flags add insets for outlying territories:</p>
102
+ <ul>
103
+ <li><code>+PR</code> — Puerto Rico</li>
104
+ <li><code>+VI</code> — U.S. Virgin Islands (placed alongside Puerto Rico)</li>
105
+ </ul>
106
+ <pre><code class="hljs language-bash">mapshaper us-states.shp -proj albersusa +PR +VI -o
107
+ </code></pre>
108
+ <p>The position, scale, rotation, and other properties of each inset can be overridden with named parameters if the defaults do not suit your map. See the <a href="/docs/reference.html#-proj"><code>-proj</code> reference</a> for the full option syntax.</p>
109
+ <h2 id="finding-crs-definitions">Finding CRS definitions</h2>
110
+ <p>Several websites provide PROJ strings and EPSG codes for coordinate systems worldwide:</p>
111
+ <ul>
112
+ <li><strong><a href="https://epsg.io/">EPSG.io</a></strong> — search by place name, CRS name, or EPSG code. Each entry shows the PROJ string and WKT definition and lets you preview the projection on a map.</li>
113
+ <li><strong><a href="https://spatialreference.org/">SpatialReference.org</a></strong> — similar database built directly from the PROJ library. Good for browsing the full set of supported systems.</li>
114
+ <li><strong><a href="https://proj.org/operations/projections/">PROJ documentation</a></strong> — reference for every projection in PROJ, including all supported parameters. Mapshaper&#39;s JavaScript port supports most but not all of them; run <code>mapshaper -projections</code> to see the exact list.</li>
115
+ </ul>
116
+ <h2 id="coordinate-system-quirks-and-limitations">Coordinate system quirks and limitations</h2>
117
+ <ul>
118
+ <li><p>GeoJSON and TopoJSON files are assumed to use WGS84 when their bounding boxes fall within the normal range for decimal degree coordinates.</p>
119
+ </li>
120
+ <li><p>Mapshaper does not support coordinate transformations that require grid-shift files (for example, NAD27 → WGS84). If a transformation silently fails, this is the likely cause.</p>
121
+ </li>
122
+ <li><p>Projections that can only represent part of the globe — including orthographic (<code>ortho</code>), near-side perspective (<code>nsper</code>, <code>geos</code>), gnomonic (<code>gnom</code>), stereographic (<code>stere</code>), and Lambert Azimuthal Equal-Area (<code>laea</code>) — automatically clip input data to the projection&#39;s valid extent before projecting. This prevents distorted or invalid geometry from coordinates outside the visible area.</p>
123
+ </li>
124
+ <li><p>For projections that introduce significant curvature along straight lines, add the <code>densify</code> option to interpolate extra vertices along long segments:</p>
125
+ <pre><code class="hljs language-bash">mapshaper data.shp -proj +proj=ortho +lat_0=45 +lon_0=-100 densify -o
126
+ </code></pre>
127
+ </li>
128
+ <li><p>When <code>-proj</code> targets a layer, all topologically related layers (those sharing the same geometry) are also reprojected. To reproject all layers, use <code>target=*</code>.</p>
129
+ </li>
130
+ <li><p>The <code>init=</code> option is available for files whose source CRS is unknown and cannot be inferred from a <code>.prj</code> file. Shapefiles normally carry a <code>.prj</code> sidecar; GeoJSON and TopoJSON are assumed to be WGS84 when their coordinates fall within the standard lat/long range.</p>
131
+ </li>
132
+ </ul>
133
+ <h2 id="the--proj-command">The -proj command</h2>
134
+ <p>See the <a href="/docs/reference.html#-proj"><code>-proj</code> reference</a> for the full list of options.</p>
135
+
136
+ <div class="edit-link">
137
+ <a href="https://github.com/mbloch/mapshaper/edit/master/docs/guides/projections.md">Edit this page on GitHub</a>
138
+ </div>
139
+ </article>
140
+ </main>
141
+
142
+ <aside class="docs-toc">
143
+ <div class="docs-toc-title">On this page</div><ul><li class="lvl-2"><a href="#forms-of-crs-notation">Forms of CRS notation</a></li><li class="lvl-2"><a href="#auto-fitted-parameters">Auto-fitted parameters</a></li><li class="lvl-2"><a href="#albersusa">albersusa</a></li><li class="lvl-2"><a href="#finding-crs-definitions">Finding CRS definitions</a></li><li class="lvl-2"><a href="#coordinate-system-quirks-and-limitations">Coordinate system quirks and limitations</a></li><li class="lvl-2"><a href="#the--proj-command">The -proj command</a></li></ul>
144
+ </aside>
145
+
146
+ </div>
147
+
148
+ <script src="/docs/_assets/docs.js" defer></script>
149
+
150
+ <footer class="docs-footer">
151
+ <div class="docs-footer-inner">
152
+ <span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
153
+ <span><a href="/privacy.html">Privacy</a> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
154
+ </div>
155
+ </footer>
156
+
157
+ </body>
158
+ </html>
@@ -0,0 +1,118 @@
1
+ ---
2
+ title: Projections
3
+ description: How to reproject geographic data with Mapshaper, including CRS notation, built-in aliases, and the albersusa composite projection.
4
+ ---
5
+
6
+ # Projections
7
+
8
+ Mapshaper's [`-proj`](/docs/reference.html.md#-proj) command reprojects a dataset from one coordinate reference system (CRS) to another, using a JavaScript port of the [PROJ](https://proj.org/) coordinate transformation library.
9
+
10
+ **Examples**
11
+
12
+ ```bash
13
+ # Project a Shapefile to UTM zone 11N using a PROJ string
14
+ mapshaper nevada.shp -proj +proj=utm +zone=11 -o
15
+
16
+ # Convert a projected Shapefile to WGS84 — the following are equivalent:
17
+ mapshaper nyc.shp -proj EPSG:4326 -o
18
+ mapshaper nyc.shp -proj wgs84 -o
19
+ mapshaper nyc.shp -proj +proj=longlat +datum=WGS84 -o
20
+
21
+ # Composite projection for U.S. maps with Alaska, Hawaii, and Puerto Rico insets
22
+ mapshaper us-states.shp -proj albersusa +PR -o
23
+ ```
24
+
25
+ ## Forms of CRS notation
26
+
27
+ `-proj` accepts a CRS in any of three forms.
28
+
29
+ **PROJ strings** are sequences of `+key=value` parameters. They are the lowest-level form and expose the full set of options for each projection. Parameters that have sensible defaults (datum, units, false easting/northing) can usually be omitted.
30
+
31
+ ```bash
32
+ mapshaper data.shp -proj +proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96 -o
33
+ ```
34
+
35
+ **EPSG codes** are numeric identifiers from the [EPSG registry](https://epsg.io/). Thousands of national and regional coordinate systems have EPSG codes, making them a compact and unambiguous way to specify a CRS.
36
+
37
+ ```bash
38
+ mapshaper data.shp -proj EPSG:3857 -o # Web Mercator
39
+ mapshaper data.shp -proj EPSG:32611 -o # UTM zone 11N (WGS84)
40
+ ```
41
+
42
+ **Aliases** are short names for common projections. Run `mapshaper -projections` to print the full list. The built-in aliases are:
43
+
44
+ | Alias | Equivalent PROJ string |
45
+ |---|---|
46
+ | `wgs84` | `+proj=longlat +datum=WGS84` |
47
+ | `webmercator` | `+proj=merc +a=6378137 +b=6378137` |
48
+ | `robinson` | `+proj=robin +datum=WGS84` |
49
+ | `albersusa` | [Composite U.S. projection](#albersusa) (see below) |
50
+
51
+ You can also use a bare PROJ projection name (without `+proj=`) as shorthand when no extra parameters are required:
52
+
53
+ ```bash
54
+ mapshaper world.shp -proj robin -o
55
+ ```
56
+
57
+ ## Auto-fitted parameters
58
+
59
+ For some conic and cylindrical projections, you can supply just the projection name and Mapshaper will calculate suitable parameters from the extent of the data. This is useful when you want a locally appropriate projection without looking up specific values.
60
+
61
+ For **Lambert Conformal Conic** (`lcc`) and **Albers Equal Area Conic** (`aea`), Mapshaper calculates the central meridian (`lon_0`) and two standard parallels (`lat_1`, `lat_2`) using the one-sixth rule applied to the data's bounding box.
62
+
63
+ For **Transverse Mercator** (`tmerc`, `etmerc`), it calculates the central meridian and latitude of origin (`lon_0`, `lat_0`) from the center of the bounding box.
64
+
65
+ ```bash
66
+ # Mapshaper fills in lon_0, lat_1, lat_2 based on the data extent
67
+ mapshaper region.geojson -proj lcc -o region_lcc.geojson
68
+
69
+ # Equivalent — Mapshaper fills in lon_0 and lat_0
70
+ mapshaper region.geojson -proj tmerc -o region_tmerc.geojson
71
+ ```
72
+
73
+ When Mapshaper auto-fits parameters, it prints the expanded PROJ string so you can see exactly what was applied — for example: `Converted "lcc" to "+proj=lcc +lon_0=-95.5 +lat_1=30.17 +lat_2=44.83"`. You can copy that string and use it explicitly if you need reproducible output.
74
+
75
+ ## albersusa
76
+
77
+ `albersusa` is a Mapshaper-specific composite projection for maps of the United States. It is not part of the PROJ library. It applies Albers Equal Area Conic to the contiguous 48 states, then tiles Alaska (scaled down) and Hawaii as insets in the lower-left corner of the map.
78
+
79
+ ```bash
80
+ mapshaper us-states.shp -proj albersusa -o
81
+ ```
82
+
83
+ Two optional flags add insets for outlying territories:
84
+
85
+ - `+PR` — Puerto Rico
86
+ - `+VI` — U.S. Virgin Islands (placed alongside Puerto Rico)
87
+
88
+ ```bash
89
+ mapshaper us-states.shp -proj albersusa +PR +VI -o
90
+ ```
91
+
92
+ The position, scale, rotation, and other properties of each inset can be overridden with named parameters if the defaults do not suit your map. See the [`-proj` reference](/docs/reference.html.md#-proj) for the full option syntax.
93
+
94
+ ## Finding CRS definitions
95
+
96
+ Several websites provide PROJ strings and EPSG codes for coordinate systems worldwide:
97
+
98
+ - **[EPSG.io](https://epsg.io/)** — search by place name, CRS name, or EPSG code. Each entry shows the PROJ string and WKT definition and lets you preview the projection on a map.
99
+ - **[SpatialReference.org](https://spatialreference.org/)** — similar database built directly from the PROJ library. Good for browsing the full set of supported systems.
100
+ - **[PROJ documentation](https://proj.org/operations/projections/)** — reference for every projection in PROJ, including all supported parameters. Mapshaper's JavaScript port supports most but not all of them; run `mapshaper -projections` to see the exact list.
101
+
102
+ ## Coordinate system quirks and limitations
103
+
104
+ - GeoJSON and TopoJSON files are assumed to use WGS84 when their bounding boxes fall within the normal range for decimal degree coordinates.
105
+ - Mapshaper does not support coordinate transformations that require grid-shift files (for example, NAD27 → WGS84). If a transformation silently fails, this is the likely cause.
106
+ - Projections that can only represent part of the globe — including orthographic (`ortho`), near-side perspective (`nsper`, `geos`), gnomonic (`gnom`), stereographic (`stere`), and Lambert Azimuthal Equal-Area (`laea`) — automatically clip input data to the projection's valid extent before projecting. This prevents distorted or invalid geometry from coordinates outside the visible area.
107
+ - For projections that introduce significant curvature along straight lines, add the `densify` option to interpolate extra vertices along long segments:
108
+
109
+ ```bash
110
+ mapshaper data.shp -proj +proj=ortho +lat_0=45 +lon_0=-100 densify -o
111
+ ```
112
+
113
+ - When `-proj` targets a layer, all topologically related layers (those sharing the same geometry) are also reprojected. To reproject all layers, use `target=*`.
114
+ - The `init=` option is available for files whose source CRS is unknown and cannot be inferred from a `.prj` file. Shapefiles normally carry a `.prj` sidecar; GeoJSON and TopoJSON are assumed to be WGS84 when their coordinates fall within the standard lat/long range.
115
+
116
+ ## The -proj command
117
+
118
+ See the [`-proj` reference](/docs/reference.html.md#-proj) for the full list of options.
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Simplification &middot; mapshaper docs</title>
7
+ <meta name="description" content="How to choose between Visvalingam and Douglas-Peucker, and tips for getting good-looking results from polygon and polyline simplification.">
8
+ <link rel="icon" type="image/png" href="/images/icon.png">
9
+ <link rel="stylesheet" href="/docs/_assets/highlight.css">
10
+ <link rel="stylesheet" href="/docs/_assets/docs.css">
11
+ </head>
12
+ <body class="">
13
+
14
+ <header class="page-header">
15
+ <a href="/" class="mapshaper-logo">map<span class="logo-highlight">shaper</span></a>
16
+ <span class="header-section-label">Docs</span>
17
+ <nav class="header-nav">
18
+ <a href="/">Web app</a>
19
+ <a href="https://github.com/mbloch/mapshaper">GitHub</a>
20
+ <a href="/sponsor.html" class="sponsor-link"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg> Become a sponsor</a>
21
+ </nav>
22
+ </header>
23
+
24
+ <div class="docs-layout">
25
+
26
+ <aside class="docs-sidebar">
27
+ <div class="sidebar-inner">
28
+ <nav class="docs-nav"><ul class="top-links"><li><a href="/docs/">Home</a></li><li><a href="/docs/whats-new.html">What&#39;s new</a></li><li><a href="/docs/reference.html">Command reference</a></li><li><a href="/docs/gallery/">Gallery</a></li></ul><h2>Getting started</h2><ul><li><a href="/docs/essentials/command-line.html">The command-line tool</a></li><li><a href="/docs/essentials/web-app.html">The web app</a></li></ul><h2>Guides</h2><ul><li><a href="/docs/guides/simplification.html" class="is-active">Simplification</a></li><li><a href="/docs/guides/expressions.html">JavaScript expressions</a></li><li><a href="/docs/guides/projections.html">Projections</a></li><li><a href="/docs/guides/topology.html">Topology and cleaning</a></li><li><a href="/docs/guides/combining-layers.html">Combining two layers</a></li><li><a href="/docs/guides/programmatic.html">Using Mapshaper from Node.js</a></li></ul><h2>Formats</h2><ul><li><a href="/docs/formats/overview.html">Overview</a></li><li><a href="/docs/formats/shapefile.html">Shapefile</a></li><li><a href="/docs/formats/geojson.html">GeoJSON</a></li><li><a href="/docs/formats/topojson.html">TopoJSON</a></li><li><a href="/docs/formats/geopackage.html">GeoPackage</a></li><li><a href="/docs/formats/flatgeobuf.html">FlatGeobuf</a></li><li><a href="/docs/formats/kml.html">KML / KMZ</a></li><li><a href="/docs/formats/csv.html">CSV / TSV</a></li><li><a href="/docs/formats/dbf.html">DBF</a></li><li><a href="/docs/formats/json.html">JSON records</a></li><li><a href="/docs/formats/svg.html">SVG</a></li><li><a href="/docs/formats/snapshot.html">Mapshaper snapshot</a></li></ul><h2>Examples</h2><ul><li><a href="/docs/examples/basics.html">Basics</a></li><li><a href="/docs/examples/globe.html">Globe</a></li><li><a href="/docs/examples/us-states.html">U.S. state map</a></li></ul></nav>
29
+ </div>
30
+ </aside>
31
+
32
+ <main class="docs-main">
33
+ <article class="docs-article">
34
+ <div class="docs-breadcrumbs"><a href="/docs/">Docs</a> &rsaquo; Guides &rsaquo; Simplification</div>
35
+ <h1 id="simplification">Simplification</h1>
36
+ <p>Simplification reduces the number of vertices in polylines and polygon boundaries while preserving as much of their shape as possible. It is Mapshaper&#39;s original feature, and the workhorse for reducing large, detailed datasets to a size practical for web maps.</p>
37
+ <h2 id="choosing-a-method">Choosing a method</h2>
38
+ <p>Mapshaper offers three simplification methods, selectable as flags to <code>-simplify</code>:</p>
39
+ <ul>
40
+ <li><strong><code>dp</code></strong> &mdash; 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.</li>
41
+ <li><strong><code>visvalingam</code></strong> &mdash; The Visvalingam algorithm. Iteratively removes the point that forms the smallest triangle with its two neighbors.</li>
42
+ <li><strong><code>weighted_visvalingam</code></strong> (Mapshaper&#39;s default) &mdash; Visvalingam&#39;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. This method can be effective at generalizing very detailed source files, but be careful that it doesn&#39;t remove long, thin geographic features that you want to keep.</li>
43
+ </ul>
44
+ <p>Weighted Visvalingam is the default because it has proven to be versatile and effective at reducing detail in highly detailed source data. If you are only interested in minimizing file size, Douglas-Peucker is generally the better choice.</p>
45
+ <p>You can control the amount of weighting used by Weighted Visvalingam with the <code>weighting=</code> option (default is 0.7).</p>
46
+ <p><strong>Figures</strong></p>
47
+ <p>Natural Earth 10m coastlines, simplified with modified Visvalingam at 5% point retention.
48
+ <img src="/docs/images/simplification-mod2.png" alt="image"></p>
49
+ <p>Same file using Douglas-Peucker, also 5% simplification.
50
+ <img src="/docs/images/simplification-dp.png" alt="image"></p>
51
+ <p>Zoomed-in view of Norwegian coastline at 5% simplification; left: weighted Visvalingam, right: Douglas-Peucker.
52
+ <img src="/docs/images/simplification-detail.png" alt="image"></p>
53
+ <h2 id="simplification-amount">Simplification amount</h2>
54
+ <p>On the command line, there are three ways to specify the amount of simplification to apply: <code>percentage</code>, <code>interval</code>, and <code>resolution</code>.</p>
55
+ <p>Percentage is the default (you don&#39;t need to type <code>percentage=</code>). It gives the percentage of removable vertices to retain, so lower numbers = more simplification.</p>
56
+ <pre><code class="hljs language-bash">mapshaper provinces.geojson -simplify 20% \
57
+ -o provinces_simplified.geojson
58
+ </code></pre>
59
+ <p>The <code>interval</code> 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, <code>interval=</code> describes the approximate size of the smallest details in the simplified output.</p>
60
+ <pre><code class="hljs language-bash">mapshaper provinces.geojson -simplify interval=500m \
61
+ -o provinces_simplified.geojson
62
+ </code></pre>
63
+ <p>The <code>resolution=</code> 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.</p>
64
+ <pre><code class="hljs language-bash">mapshaper provinces.geojson -simplify resolution=800 \
65
+ -o provinces_simplified.geojson
66
+ </code></pre>
67
+ <p>See the <a href="/docs/reference.html#-simplify"><code>-simplify</code> reference</a> for the full set of options.</p>
68
+ <h2 id="avoiding-shape-removal">Avoiding shape removal</h2>
69
+ <p>At high simplification, small polygons can disappear entirely. Pass <code>keep-shapes</code> to <code>-simplify</code> (or tick <strong>prevent shape removal</strong> in the web UI&#39;s Simplify panel) to retain at least one ring per multipart feature, regardless of how aggressive the simplification is.</p>
70
+ <pre><code class="hljs language-bash">mapshaper provinces.shp -simplify 5% keep-shapes -o provinces.geojson
71
+ </code></pre>
72
+ <h2 id="spherical-vs-planar-geometry">Spherical vs planar geometry</h2>
73
+ <p>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.</p>
74
+ <h2 id="avoiding-self-intersections">Avoiding self-intersections</h2>
75
+ <p>Heavy simplification can pull adjacent polygon edges across each other, producing self-intersections. The <code>-simplify</code> command detects and tries to remove intersections automatically by rolling back simplification where the intersections occur. In the web UI, you can enable &quot;detect line intersections&quot; on the Display panel to show intersections as red dots. In this mode, you will see a button for repairing intersections caused by simplification.</p>
76
+ <p>The <a href="/docs/reference.html#-clean"><code>-clean</code></a> command will also remove intersections:</p>
77
+ <pre><code class="hljs language-bash">mapshaper provinces.shp -simplify 5% -clean -o provinces.geojson
78
+ </code></pre>
79
+ <h2 id="simplifying-multiple-layers-consistently">Simplifying multiple layers consistently</h2>
80
+ <p>When you import multiple layers using <code>-i combine-files</code>, 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.
81
+ Without this, the layers would diverge during simplification, creating visible gaps and overlaps where they should align.</p>
82
+ <pre><code class="hljs language-bash">mapshaper -i states.shp counties.shp combine-files \
83
+ -simplify 10% \
84
+ -o out/
85
+ </code></pre>
86
+ <p>The web app does <strong>not</strong> combine files automatically when you import multiple layers. To get the shared-topology behavior in the web app, tick <strong>with advanced options</strong> in the import dialog and add <code>combine-files</code> to the options field.</p>
87
+
88
+ <div class="edit-link">
89
+ <a href="https://github.com/mbloch/mapshaper/edit/master/docs/guides/simplification.md">Edit this page on GitHub</a>
90
+ </div>
91
+ </article>
92
+ </main>
93
+
94
+ <aside class="docs-toc">
95
+ <div class="docs-toc-title">On this page</div><ul><li class="lvl-2"><a href="#choosing-a-method">Choosing a method</a></li><li class="lvl-2"><a href="#simplification-amount">Simplification amount</a></li><li class="lvl-2"><a href="#avoiding-shape-removal">Avoiding shape removal</a></li><li class="lvl-2"><a href="#spherical-vs-planar-geometry">Spherical vs planar geometry</a></li><li class="lvl-2"><a href="#avoiding-self-intersections">Avoiding self-intersections</a></li><li class="lvl-2"><a href="#simplifying-multiple-layers-consistently">Simplifying multiple layers consistently</a></li></ul>
96
+ </aside>
97
+
98
+ </div>
99
+
100
+ <script src="/docs/_assets/docs.js" defer></script>
101
+
102
+ <footer class="docs-footer">
103
+ <div class="docs-footer-inner">
104
+ <span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
105
+ <span><a href="/privacy.html">Privacy</a> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
106
+ </div>
107
+ </footer>
108
+
109
+ </body>
110
+ </html>
@@ -0,0 +1,94 @@
1
+ ---
2
+ title: Simplification
3
+ description: How to choose between Visvalingam and Douglas-Peucker, and tips for getting good-looking results from polygon and polyline simplification.
4
+ ---
5
+
6
+ # Simplification
7
+
8
+ 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.
9
+
10
+ ## Choosing a method
11
+
12
+ Mapshaper offers three simplification methods, selectable as flags to `-simplify`:
13
+
14
+ - **`dp`** &mdash; 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.
15
+ - **`visvalingam`** &mdash; The Visvalingam algorithm. Iteratively removes the point that forms the smallest triangle with its two neighbors.
16
+ - **`weighted_visvalingam`** (Mapshaper's default) &mdash; 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. 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.
17
+
18
+ Weighted Visvalingam is the default because it has proven to be versatile and effective at reducing detail in highly detailed source data. If you are only interested in minimizing file size, Douglas-Peucker is generally the better choice.
19
+
20
+ You can control the amount of weighting used by Weighted Visvalingam with the `weighting=` option (default is 0.7).
21
+
22
+ **Figures**
23
+
24
+ Natural Earth 10m coastlines, simplified with modified Visvalingam at 5% point retention.
25
+ ![image](/docs/images/simplification-mod2.png)
26
+
27
+ Same file using Douglas-Peucker, also 5% simplification.
28
+ ![image](/docs/images/simplification-dp.png)
29
+
30
+ Zoomed-in view of Norwegian coastline at 5% simplification; left: weighted Visvalingam, right: Douglas-Peucker.
31
+ ![image](/docs/images/simplification-detail.png)
32
+
33
+ ## Simplification amount
34
+
35
+ On the command line, there are three ways to specify the amount of simplification to apply: `percentage`, `interval`, and `resolution`.
36
+
37
+ 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.
38
+
39
+ ```bash
40
+ mapshaper provinces.geojson -simplify 20% \
41
+ -o provinces_simplified.geojson
42
+ ```
43
+
44
+ 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.
45
+
46
+ ```bash
47
+ mapshaper provinces.geojson -simplify interval=500m \
48
+ -o provinces_simplified.geojson
49
+ ```
50
+
51
+ 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.
52
+
53
+ ```bash
54
+ mapshaper provinces.geojson -simplify resolution=800 \
55
+ -o provinces_simplified.geojson
56
+ ```
57
+
58
+ See the [`-simplify` reference](/docs/reference.html.md#-simplify) for the full set of options.
59
+
60
+
61
+ ## Avoiding shape removal
62
+
63
+ 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.
64
+
65
+ ```bash
66
+ mapshaper provinces.shp -simplify 5% keep-shapes -o provinces.geojson
67
+ ```
68
+
69
+ ## Spherical vs planar geometry
70
+
71
+ 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.
72
+
73
+ ## Avoiding self-intersections
74
+
75
+ 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.
76
+
77
+ The [`-clean`](/docs/reference.html.md#-clean) command will also remove intersections:
78
+
79
+ ```bash
80
+ mapshaper provinces.shp -simplify 5% -clean -o provinces.geojson
81
+ ```
82
+
83
+ ## Simplifying multiple layers consistently
84
+
85
+ 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.
86
+ Without this, the layers would diverge during simplification, creating visible gaps and overlaps where they should align.
87
+
88
+ ```bash
89
+ mapshaper -i states.shp counties.shp combine-files \
90
+ -simplify 10% \
91
+ -o out/
92
+ ```
93
+
94
+ 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.
@@ -0,0 +1,90 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Topology and cleaning &middot; mapshaper docs</title>
7
+ <meta name="description" content="How Mapshaper detects shared boundaries between features, and how to fix the common topology errors that creep into Shapefile and GeoJSON datasets.">
8
+ <link rel="icon" type="image/png" href="/images/icon.png">
9
+ <link rel="stylesheet" href="/docs/_assets/highlight.css">
10
+ <link rel="stylesheet" href="/docs/_assets/docs.css">
11
+ </head>
12
+ <body class="">
13
+
14
+ <header class="page-header">
15
+ <a href="/" class="mapshaper-logo">map<span class="logo-highlight">shaper</span></a>
16
+ <span class="header-section-label">Docs</span>
17
+ <nav class="header-nav">
18
+ <a href="/">Web app</a>
19
+ <a href="https://github.com/mbloch/mapshaper">GitHub</a>
20
+ <a href="/sponsor.html" class="sponsor-link"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg> Become a sponsor</a>
21
+ </nav>
22
+ </header>
23
+
24
+ <div class="docs-layout">
25
+
26
+ <aside class="docs-sidebar">
27
+ <div class="sidebar-inner">
28
+ <nav class="docs-nav"><ul class="top-links"><li><a href="/docs/">Home</a></li><li><a href="/docs/whats-new.html">What&#39;s new</a></li><li><a href="/docs/reference.html">Command reference</a></li><li><a href="/docs/gallery/">Gallery</a></li></ul><h2>Getting started</h2><ul><li><a href="/docs/essentials/command-line.html">The command-line tool</a></li><li><a href="/docs/essentials/web-app.html">The web app</a></li></ul><h2>Guides</h2><ul><li><a href="/docs/guides/simplification.html">Simplification</a></li><li><a href="/docs/guides/expressions.html">JavaScript expressions</a></li><li><a href="/docs/guides/projections.html">Projections</a></li><li><a href="/docs/guides/topology.html" class="is-active">Topology and cleaning</a></li><li><a href="/docs/guides/combining-layers.html">Combining two layers</a></li><li><a href="/docs/guides/programmatic.html">Using Mapshaper from Node.js</a></li></ul><h2>Formats</h2><ul><li><a href="/docs/formats/overview.html">Overview</a></li><li><a href="/docs/formats/shapefile.html">Shapefile</a></li><li><a href="/docs/formats/geojson.html">GeoJSON</a></li><li><a href="/docs/formats/topojson.html">TopoJSON</a></li><li><a href="/docs/formats/geopackage.html">GeoPackage</a></li><li><a href="/docs/formats/flatgeobuf.html">FlatGeobuf</a></li><li><a href="/docs/formats/kml.html">KML / KMZ</a></li><li><a href="/docs/formats/csv.html">CSV / TSV</a></li><li><a href="/docs/formats/dbf.html">DBF</a></li><li><a href="/docs/formats/json.html">JSON records</a></li><li><a href="/docs/formats/svg.html">SVG</a></li><li><a href="/docs/formats/snapshot.html">Mapshaper snapshot</a></li></ul><h2>Examples</h2><ul><li><a href="/docs/examples/basics.html">Basics</a></li><li><a href="/docs/examples/globe.html">Globe</a></li><li><a href="/docs/examples/us-states.html">U.S. state map</a></li></ul></nav>
29
+ </div>
30
+ </aside>
31
+
32
+ <main class="docs-main">
33
+ <article class="docs-article">
34
+ <div class="docs-breadcrumbs"><a href="/docs/">Docs</a> &rsaquo; Guides &rsaquo; Topology and cleaning</div>
35
+ <h1 id="topology-and-cleaning">Topology and cleaning</h1>
36
+ <p>Shapefile and GeoJSON are non-topological formats &mdash; they don&#39;t record the spatial relationships between adjacent polygons or intersecting polylines. Each polygon is just a list of coordinates; whether two polygons share an edge has to be detected.</p>
37
+ <p>Mapshaper detects topology on import by identifying coordinates that are exactly shared between features. This is what makes operations like simplification, dissolving and clipping work correctly: when two polygons share an edge, the shared path (or &quot;arc&quot;) is stored once and edited once.</p>
38
+ <p>But coordinates that &quot;should be&quot; identical often aren&#39;t. Source datasets routinely contain misalignments (tiny gaps or overlaps between adjacent polygons) that defeat exact-match topology detection. The result is that what looks like a clean boundary turns into duplicated, slightly-offset arcs &mdash; and simplification, dissolving and clipping all start to misbehave.</p>
39
+ <h2 id="snapping">Snapping</h2>
40
+ <p>The simplest fix is to ask Mapshaper to snap nearby vertices together at import time.</p>
41
+ <p>In the <strong>command line</strong>, pass the <code>snap</code> flag to <code>-i</code>:</p>
42
+ <pre><code class="hljs language-bash">mapshaper countries.shp snap -dissolve CONTINENT -o continents.shp
43
+ </code></pre>
44
+ <p>In the <strong>web app</strong>, tick &quot;snap vertices&quot; in the import dialog (open the import options with the <strong>with advanced options</strong> checkbox).</p>
45
+ <p>By default, snapping uses an automatic threshold of about 0.0025× the average segment length, which is designed to catch misalignments caused by floating-point rounding. To set an explicit snapping distance, use <code>snap-interval=</code>:</p>
46
+ <pre><code class="hljs language-bash">mapshaper countries.shp snap-interval=0.0001 -o cleaned.shp
47
+ </code></pre>
48
+ <h2 id="cleaning">Cleaning</h2>
49
+ <p>Snapping handles slightly offset pairs of vertices, but doesn&#39;t help much when adjacent polygons have small overlapping regions or gaps along their shared boundaries. The <a href="/docs/reference.html#-clean"><code>-clean</code></a> command repairs these by recomputing the polygon mosaic and snapping geometry that&#39;s nearly identical:</p>
50
+ <pre><code class="hljs language-bash">mapshaper countries.shp -clean -o cleaned.shp
51
+ </code></pre>
52
+ <p><code>-clean</code> accepts a <code>gap-fill-area=</code> option to control how aggressively gaps are filled, and a <code>sliver-control=</code> setting for handling sliver polygons. <a href="/docs/reference.html#-dissolve"><code>-dissolve</code></a> runs an equivalent repair by default, so explicitly running <code>-clean</code> is mainly useful when you want clean output without dissolving anything.</p>
53
+ <p>In the web app, <code>-clean</code> runs from the <strong>Console</strong> the same way as on the CLI &mdash; the leading <code>-</code> is optional, e.g. just <code>clean gap-fill-area=100</code>.</p>
54
+ <h2 id="dissolving-with-topology-repair">Dissolving with topology repair</h2>
55
+ <p><a href="/docs/reference.html#-dissolve"><code>-dissolve</code></a> repairs topology automatically. To skip the repair pass (faster, but only safe when you trust the input topology), pass <code>no-repair</code> &mdash; Mapshaper will then warn if it detects segment intersections in the input.</p>
56
+ <pre><code class="hljs language-bash">mapshaper counties.shp -dissolve STATE_FIPS -o states.shp
57
+ </code></pre>
58
+ <h2 id="detecting-line-intersections">Detecting line intersections</h2>
59
+ <p>The web app can highlight self-intersections in your data: open the <strong>Display</strong> panel and tick &quot;detect line intersections&quot;. Intersections often indicate either a topology error in the source data or self-intersections introduced by simplification &mdash; the <strong>Repair</strong> button at the top-left of the map attempts to fix the latter.</p>
60
+ <p>On the command line, <a href="/docs/reference.html#-clean"><code>-clean</code></a> and <a href="/docs/reference.html#-dissolve"><code>-dissolve</code></a> both detect and fix intersections.</p>
61
+ <h2 id="notes-on-common-sources-of-topology-errors">Notes on common sources of topology errors</h2>
62
+ <p>A few patterns to watch out for:</p>
63
+ <ul>
64
+ <li><strong><code>.shp</code> files exported from older GIS tools.</strong> Some pipelines round coordinates inconsistently between adjacent features, producing systematic misalignments. Importing with <code>snap</code> is usually enough.</li>
65
+ <li><strong>Older versions of ArcGIS&#39;s dissolve tool</strong> have been observed to produce topology errors when dissolving a Shapefile that hasn&#39;t first been added to a Geodatabase. If you&#39;re starting from such output, run it through <code>mapshaper input.shp -clean -o cleaned.shp</code> to repair before further processing.</li>
66
+ </ul>
67
+
68
+ <div class="edit-link">
69
+ <a href="https://github.com/mbloch/mapshaper/edit/master/docs/guides/topology.md">Edit this page on GitHub</a>
70
+ </div>
71
+ </article>
72
+ </main>
73
+
74
+ <aside class="docs-toc">
75
+ <div class="docs-toc-title">On this page</div><ul><li class="lvl-2"><a href="#snapping">Snapping</a></li><li class="lvl-2"><a href="#cleaning">Cleaning</a></li><li class="lvl-2"><a href="#dissolving-with-topology-repair">Dissolving with topology repair</a></li><li class="lvl-2"><a href="#detecting-line-intersections">Detecting line intersections</a></li><li class="lvl-2"><a href="#notes-on-common-sources-of-topology-errors">Notes on common sources of topology errors</a></li></ul>
76
+ </aside>
77
+
78
+ </div>
79
+
80
+ <script src="/docs/_assets/docs.js" defer></script>
81
+
82
+ <footer class="docs-footer">
83
+ <div class="docs-footer-inner">
84
+ <span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
85
+ <span><a href="/privacy.html">Privacy</a> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
86
+ </div>
87
+ </footer>
88
+
89
+ </body>
90
+ </html>