mapshaper 0.7.2 → 0.7.4

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/LICENSE +1 -1
  2. package/bin/mapshaper-gui +31 -7
  3. package/mapshaper.js +45 -42
  4. package/package.json +8 -7
  5. package/www/geopackage.js +10 -10
  6. package/www/index.html +32 -4
  7. package/www/mapshaper-gui.js +529 -83
  8. package/www/mapshaper.js +45 -42
  9. package/www/modules.js +5 -5
  10. package/www/page.css +157 -0
  11. package/www/docs/_assets/cmd-search.js +0 -213
  12. package/www/docs/_assets/docs.css +0 -722
  13. package/www/docs/_assets/docs.js +0 -75
  14. package/www/docs/_assets/highlight.css +0 -10
  15. package/www/docs/essentials/command-line.html +0 -127
  16. package/www/docs/essentials/command-line.html.md +0 -112
  17. package/www/docs/essentials/web-app.html +0 -138
  18. package/www/docs/essentials/web-app.html.md +0 -106
  19. package/www/docs/examples/basics.html +0 -275
  20. package/www/docs/examples/basics.html.md +0 -370
  21. package/www/docs/examples/data/Makefile +0 -31
  22. package/www/docs/examples/data/globe.msx +0 -0
  23. package/www/docs/examples/data/globe.svg +0 -616
  24. package/www/docs/examples/data/globe.txt +0 -21
  25. package/www/docs/examples/data/globe.zip +0 -0
  26. package/www/docs/examples/data/ne_50m_admin_0_countries.geojson +0 -1
  27. package/www/docs/examples/data/ne_50m_admin_1_states_provinces_lakes.geojson +0 -1
  28. package/www/docs/examples/data/us-states.msx +0 -0
  29. package/www/docs/examples/data/us-states.svg +0 -56
  30. package/www/docs/examples/data/us-states.txt +0 -6
  31. package/www/docs/examples/data/us-states.zip +0 -0
  32. package/www/docs/examples/globe.html +0 -108
  33. package/www/docs/examples/globe.html.md +0 -64
  34. package/www/docs/examples/us-states.html +0 -88
  35. package/www/docs/examples/us-states.html.md +0 -44
  36. package/www/docs/formats/csv.html +0 -127
  37. package/www/docs/formats/csv.html.md +0 -97
  38. package/www/docs/formats/dbf.html +0 -87
  39. package/www/docs/formats/dbf.html.md +0 -39
  40. package/www/docs/formats/flatgeobuf.html +0 -85
  41. package/www/docs/formats/flatgeobuf.html.md +0 -41
  42. package/www/docs/formats/geojson.html +0 -107
  43. package/www/docs/formats/geojson.html.md +0 -65
  44. package/www/docs/formats/geopackage.html +0 -87
  45. package/www/docs/formats/geopackage.html.md +0 -42
  46. package/www/docs/formats/json.html +0 -83
  47. package/www/docs/formats/json.html.md +0 -35
  48. package/www/docs/formats/kml.html +0 -82
  49. package/www/docs/formats/kml.html.md +0 -39
  50. package/www/docs/formats/overview.html +0 -191
  51. package/www/docs/formats/overview.html.md +0 -34
  52. package/www/docs/formats/shapefile.html +0 -123
  53. package/www/docs/formats/shapefile.html.md +0 -84
  54. package/www/docs/formats/snapshot.html +0 -87
  55. package/www/docs/formats/snapshot.html.md +0 -39
  56. package/www/docs/formats/svg.html +0 -99
  57. package/www/docs/formats/svg.html.md +0 -51
  58. package/www/docs/formats/topojson.html +0 -102
  59. package/www/docs/formats/topojson.html.md +0 -54
  60. package/www/docs/gallery/index.html +0 -80
  61. package/www/docs/gallery/index.html.md +0 -29
  62. package/www/docs/guides/combining-layers.html +0 -109
  63. package/www/docs/guides/combining-layers.html.md +0 -89
  64. package/www/docs/guides/expressions.html +0 -600
  65. package/www/docs/guides/expressions.html.md +0 -376
  66. package/www/docs/guides/programmatic.html +0 -117
  67. package/www/docs/guides/programmatic.html.md +0 -91
  68. package/www/docs/guides/projections.html +0 -158
  69. package/www/docs/guides/projections.html.md +0 -118
  70. package/www/docs/guides/simplification.html +0 -110
  71. package/www/docs/guides/simplification.html.md +0 -96
  72. package/www/docs/guides/topology.html +0 -90
  73. package/www/docs/guides/topology.html.md +0 -63
  74. package/www/docs/images/cal-counties.png +0 -0
  75. package/www/docs/images/simplification-detail.png +0 -0
  76. package/www/docs/images/simplification-dp.png +0 -0
  77. package/www/docs/images/simplification-mod2.png +0 -0
  78. package/www/docs/images/tiger-counties.png +0 -0
  79. package/www/docs/index.html +0 -101
  80. package/www/docs/index.html.md +0 -59
  81. package/www/docs/reference.html +0 -1302
  82. package/www/docs/reference.html.md +0 -1817
  83. package/www/docs/whats-new.html +0 -77
  84. package/www/docs/whats-new.html.md +0 -59
  85. package/www/llms-full.txt +0 -4053
  86. package/www/llms.txt +0 -55
@@ -1,75 +0,0 @@
1
- // Tiny client-side helpers for the docs site.
2
- //
3
- // 1. Rewrites "Open in the web app" links so they target the current
4
- // origin. At build time, build-docs.mjs renders the link with `href`
5
- // pointing at https://mapshaper.org/?files=https%3A%2F%2Fmapshaper.org%2F...
6
- // and a `data-open-snapshot="/docs/.../foo.msx"` attribute holding the
7
- // snapshot's site-root-relative path. On page load we recompute href
8
- // against `location.origin` so the link works when the docs are
9
- // previewed locally (typically via `mapshaper-gui`, which serves www/
10
- // on localhost:NNNN), and continues to do the right thing on the
11
- // production site.
12
- //
13
- // 2. Adds a "Copy" button to every code block on individual example-map
14
- // pages (body.is-example-map). Skipped on the Basics index, whose code
15
- // blocks are short snippets where the buttons would be visual noise.
16
- // Falls back gracefully if the Clipboard API is unavailable.
17
- (function () {
18
- rewriteOpenInWebAppLinks();
19
- if (document.body.classList.contains('is-example-map')) {
20
- addCopyButtons();
21
- }
22
-
23
- function rewriteOpenInWebAppLinks() {
24
- var links = document.querySelectorAll('a[data-open-snapshot]');
25
- if (!links.length) return;
26
- var origin = location.origin;
27
- for (var i = 0; i < links.length; i++) {
28
- var a = links[i];
29
- var path = a.getAttribute('data-open-snapshot') || '';
30
- if (!path) continue;
31
- var absUrl = origin + path;
32
- a.href = origin + '/?files=' + encodeURIComponent(absUrl) + '&q';
33
- }
34
- }
35
-
36
- function addCopyButtons() {
37
- if (!navigator.clipboard || !navigator.clipboard.writeText) return;
38
- var blocks = document.querySelectorAll('.docs-article pre');
39
- for (var i = 0; i < blocks.length; i++) {
40
- attachCopyButton(blocks[i]);
41
- }
42
- }
43
-
44
- function attachCopyButton(pre) {
45
- if (pre.querySelector(':scope > .copy-btn')) return; // already wired
46
- pre.classList.add('has-copy-btn');
47
- var btn = document.createElement('button');
48
- btn.type = 'button';
49
- btn.className = 'copy-btn';
50
- btn.setAttribute('aria-label', 'Copy code to clipboard');
51
- btn.textContent = 'Copy';
52
- btn.addEventListener('click', function () {
53
- var code = pre.querySelector('code') || pre;
54
- var text = code.innerText.replace(/\n$/, '');
55
- navigator.clipboard.writeText(text).then(function () {
56
- flash(btn, 'Copied');
57
- }, function () {
58
- flash(btn, 'Copy failed');
59
- });
60
- });
61
- pre.appendChild(btn);
62
- }
63
-
64
- var flashTimer = null;
65
- function flash(btn, label) {
66
- var original = 'Copy';
67
- btn.textContent = label;
68
- btn.classList.add('is-flashing');
69
- if (flashTimer) clearTimeout(flashTimer);
70
- flashTimer = setTimeout(function () {
71
- btn.textContent = original;
72
- btn.classList.remove('is-flashing');
73
- }, 1400);
74
- }
75
- })();
@@ -1,10 +0,0 @@
1
- pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
2
- Theme: GitHub Dark
3
- Description: Dark theme as seen on github.com
4
- Author: github.com
5
- Maintainer: @Hirse
6
- Updated: 2021-05-15
7
-
8
- Outdated base version: https://github.com/primer/github-syntax-dark
9
- Current colors taken from GitHub's CSS
10
- */.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}
@@ -1,127 +0,0 @@
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>The command-line tool &middot; mapshaper docs</title>
7
- <meta name="description" content="Install the mapshaper CLI, run your first commands and learn how Mapshaper organizes data into layers.">
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" class="is-active">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">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; Getting started &rsaquo; The command-line tool</div>
35
- <h1 id="the-command-line-tool">The command-line tool</h1>
36
- <p>Mapshaper ships as a command-line tool and a <a href="/docs/essentials/web-app.html">web app</a>. This page is a tour of the CLI and the most common things you&#39;ll use it for.</p>
37
- <h2 id="install">Install</h2>
38
- <p>Mapshaper requires <a href="https://nodejs.org">Node.js</a>. With Node installed:</p>
39
- <pre><code class="hljs language-bash">npm install -g mapshaper
40
- </code></pre>
41
- <p>That gives you three executables:</p>
42
- <ul>
43
- <li><code>mapshaper</code> &mdash; the main CLI.</li>
44
- <li><code>mapshaper-xl</code> &mdash; same as <code>mapshaper</code>, but launched with a larger Node heap (8 GB by default) for processing very large files. Override the limit with <code>mapshaper-xl 16gb [commands]</code>.</li>
45
- <li><code>mapshaper-gui</code> &mdash; runs the <a href="/docs/essentials/web-app.html">web UI</a> locally on <code>http://localhost:5555</code>.</li>
46
- </ul>
47
- <p>You can also run mapshaper without installing it via <a href="https://bun.sh/">Bun</a> (<code>bunx mapshaper [commands]</code>) or with <code>npx mapshaper [commands]</code>.</p>
48
- <p>Check the install with:</p>
49
- <pre><code class="hljs language-bash">mapshaper -v
50
- </code></pre>
51
- <h2 id="anatomy-of-a-mapshaper-command">Anatomy of a Mapshaper command</h2>
52
- <p>A Mapshaper invocation is a sequence of commands run left-to-right. Each command starts with a hyphen-prefixed name and is followed by zero or more options. The initial <code>-i</code> (input) command is implied if the first argument is a file path.</p>
53
- <pre><code class="hljs language-bash">mapshaper provinces.shp -simplify dp 20% -o precision=0.00001 output.geojson
54
- </code></pre>
55
- <p>This reads a Shapefile, simplifies it using the Douglas-Peucker algorithm to 20% of its vertices, and writes a GeoJSON file with rounded coordinates.</p>
56
- <p>Options come in three forms:</p>
57
- <ul>
58
- <li><strong>Values</strong> like <code>provinces.shp</code> and <code>output.geojson</code>.</li>
59
- <li><strong>Flags</strong> like <code>dp</code>.</li>
60
- <li><strong>Name/value pairs</strong> like <code>precision=0.00001</code>.</li>
61
- </ul>
62
- <p>For the full reference, see the <a href="/docs/reference.html">command reference</a>.</p>
63
- <h2 id="some-examples">Some examples</h2>
64
- <h3 id="get-help">Get help</h3>
65
- <pre><code class="hljs language-bash">mapshaper -h <span class="hljs-comment"># list all commands</span>
66
- mapshaper -h simplify <span class="hljs-comment"># detailed options for one command</span>
67
- </code></pre>
68
- <h3 id="chain-commands">Chain commands</h3>
69
- <pre><code class="hljs language-bash"><span class="hljs-comment"># From census blocks: dissolve populated Census blocks to tract level.</span>
70
- mapshaper tabblock2010_36_pophu.shp \
71
- -filter <span class="hljs-string">&#x27;POP10 &gt; 0&#x27;</span> \
72
- -each <span class="hljs-string">&#x27;TRACT=BLOCKID10.substr(0,11)&#x27;</span> \
73
- -dissolve TRACT sum-fields=POP10 \
74
- -o tracts.shp
75
- </code></pre>
76
- <pre><code class="hljs language-bash"><span class="hljs-comment"># Generate state and national boundaries from one county-level Shapefile.</span>
77
- <span class="hljs-comment"># Output: states.shp, usa.shp and other Shapefile component files</span>
78
- mapshaper counties.shp \
79
- -dissolve STATE_FIPS name=states \
80
- -dissolve + name=usa \
81
- -o target=<span class="hljs-string">&#x27;*&#x27;</span>
82
- </code></pre>
83
- <p>For a broader set of recipes — filtering, joining, dissolving, reprojection, styling and more — see <a href="/docs/examples/basics.html">Basics</a>.</p>
84
- <h2 id="working-with-layers">Working with layers</h2>
85
- <p>Most commands operate on <strong>layers</strong> of data features. A layer is a collection of features with the same geometry type and a consistent attribute schema. Mapshaper supports polygon, polyline and point layers; a single feature may contain one shape, multiple shapes, or no shapes at all.</p>
86
- <p>The simplest case is a single layer in, a single layer out:</p>
87
- <pre><code class="hljs language-bash">mapshaper counties.shp -filter <span class="hljs-string">&#x27;this.isNull === false&#x27;</span> -o counties_notnull.shp
88
- </code></pre>
89
- <p>When a command runs on a multi-layer dataset, it acts on the <strong>target</strong> layer(s). Most commands accept a <code>target=</code> option, and the <a href="/docs/reference.html#-target"><code>-target</code></a> command sets the target for everything that follows.</p>
90
- <p>The <code>+</code> option keeps the original layer and creates a new one from the command&#39;s output. Combined with <code>name=</code>, it&#39;s the idiomatic way to derive a new layer:</p>
91
- <pre><code class="hljs language-bash"><span class="hljs-comment"># Output: out/provinces.json and out/lines.json</span>
92
- mapshaper provinces.shp \
93
- -simplify 20% \
94
- -innerlines + name=lines \
95
- -target provinces,lines \
96
- -o format=geojson out/
97
- </code></pre>
98
- <p>This produces <code>out/provinces.json</code> and <code>out/lines.json</code>.</p>
99
- <p>When importing a TopoJSON file, each named object becomes a layer:</p>
100
- <pre><code class="hljs language-bash">mapshaper usa.topojson \
101
- -filter <span class="hljs-string">&#x27;STATE == &quot;HI&quot;&#x27;</span> target=states \
102
- -o out/hawaii.geojson
103
- </code></pre>
104
-
105
- <div class="edit-link">
106
- <a href="https://github.com/mbloch/mapshaper/edit/master/docs/essentials/command-line.md">Edit this page on GitHub</a>
107
- </div>
108
- </article>
109
- </main>
110
-
111
- <aside class="docs-toc">
112
- <div class="docs-toc-title">On this page</div><ul><li class="lvl-2"><a href="#install">Install</a></li><li class="lvl-2"><a href="#anatomy-of-a-mapshaper-command">Anatomy of a Mapshaper command</a></li><li class="lvl-2"><a href="#some-examples">Some examples</a></li><li class="lvl-3"><a href="#get-help">Get help</a></li><li class="lvl-3"><a href="#chain-commands">Chain commands</a></li><li class="lvl-2"><a href="#working-with-layers">Working with layers</a></li></ul>
113
- </aside>
114
-
115
- </div>
116
-
117
- <script src="/docs/_assets/docs.js" defer></script>
118
-
119
- <footer class="docs-footer">
120
- <div class="docs-footer-inner">
121
- <span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
122
- <span><a href="/privacy.html">Privacy</a> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
123
- </div>
124
- </footer>
125
-
126
- </body>
127
- </html>
@@ -1,112 +0,0 @@
1
- ---
2
- title: The command-line tool
3
- description: Install the mapshaper CLI, run your first commands and learn how Mapshaper organizes data into layers.
4
- ---
5
-
6
- # The command-line tool
7
-
8
- Mapshaper ships as a command-line tool and a [web app](/docs/essentials/web-app.html.md). This page is a tour of the CLI and the most common things you'll use it for.
9
-
10
- ## Install
11
-
12
- Mapshaper requires [Node.js](https://nodejs.org). With Node installed:
13
-
14
- ```bash
15
- npm install -g mapshaper
16
- ```
17
-
18
- That gives you three executables:
19
-
20
- - `mapshaper` &mdash; the main CLI.
21
- - `mapshaper-xl` &mdash; same as `mapshaper`, but launched with a larger Node heap (8 GB by default) for processing very large files. Override the limit with `mapshaper-xl 16gb [commands]`.
22
- - `mapshaper-gui` &mdash; runs the [web UI](/docs/essentials/web-app.html.md) locally on `http://localhost:5555`.
23
-
24
- You can also run mapshaper without installing it via [Bun](https://bun.sh/) (`bunx mapshaper [commands]`) or with `npx mapshaper [commands]`.
25
-
26
- Check the install with:
27
-
28
- ```bash
29
- mapshaper -v
30
- ```
31
-
32
- ## Anatomy of a Mapshaper command
33
-
34
- A Mapshaper invocation is a sequence of commands run left-to-right. Each command starts with a hyphen-prefixed name and is followed by zero or more options. The initial `-i` (input) command is implied if the first argument is a file path.
35
-
36
- ```bash
37
- mapshaper provinces.shp -simplify dp 20% -o precision=0.00001 output.geojson
38
- ```
39
-
40
- This reads a Shapefile, simplifies it using the Douglas-Peucker algorithm to 20% of its vertices, and writes a GeoJSON file with rounded coordinates.
41
-
42
- Options come in three forms:
43
-
44
- - **Values** like `provinces.shp` and `output.geojson`.
45
- - **Flags** like `dp`.
46
- - **Name/value pairs** like `precision=0.00001`.
47
-
48
- For the full reference, see the [command reference](/docs/reference.html.md).
49
-
50
- ## Some examples
51
-
52
- ### Get help
53
-
54
- ```bash
55
- mapshaper -h # list all commands
56
- mapshaper -h simplify # detailed options for one command
57
- ```
58
-
59
- ### Chain commands
60
-
61
- ```bash
62
- # From census blocks: dissolve populated Census blocks to tract level.
63
- mapshaper tabblock2010_36_pophu.shp \
64
- -filter 'POP10 > 0' \
65
- -each 'TRACT=BLOCKID10.substr(0,11)' \
66
- -dissolve TRACT sum-fields=POP10 \
67
- -o tracts.shp
68
- ```
69
-
70
- ```bash
71
- # Generate state and national boundaries from one county-level Shapefile.
72
- # Output: states.shp, usa.shp and other Shapefile component files
73
- mapshaper counties.shp \
74
- -dissolve STATE_FIPS name=states \
75
- -dissolve + name=usa \
76
- -o target='*'
77
- ```
78
-
79
- For a broader set of recipes — filtering, joining, dissolving, reprojection, styling and more — see [Basics](/docs/examples/basics.html.md).
80
-
81
- ## Working with layers
82
-
83
- Most commands operate on **layers** of data features. A layer is a collection of features with the same geometry type and a consistent attribute schema. Mapshaper supports polygon, polyline and point layers; a single feature may contain one shape, multiple shapes, or no shapes at all.
84
-
85
- The simplest case is a single layer in, a single layer out:
86
-
87
- ```bash
88
- mapshaper counties.shp -filter 'this.isNull === false' -o counties_notnull.shp
89
- ```
90
-
91
- When a command runs on a multi-layer dataset, it acts on the **target** layer(s). Most commands accept a `target=` option, and the [`-target`](/docs/reference.html.md#-target) command sets the target for everything that follows.
92
-
93
- The `+` option keeps the original layer and creates a new one from the command's output. Combined with `name=`, it's the idiomatic way to derive a new layer:
94
-
95
- ```bash
96
- # Output: out/provinces.json and out/lines.json
97
- mapshaper provinces.shp \
98
- -simplify 20% \
99
- -innerlines + name=lines \
100
- -target provinces,lines \
101
- -o format=geojson out/
102
- ```
103
-
104
- This produces `out/provinces.json` and `out/lines.json`.
105
-
106
- When importing a TopoJSON file, each named object becomes a layer:
107
-
108
- ```bash
109
- mapshaper usa.topojson \
110
- -filter 'STATE == "HI"' target=states \
111
- -o out/hawaii.geojson
112
- ```
@@ -1,138 +0,0 @@
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>The web app &middot; mapshaper docs</title>
7
- <meta name="description" content="A tour of Mapshaper&#39;s web interface, including loading data, the console, the right-click menu, snapshots, browser support and running it locally.">
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" class="is-active">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">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; Getting started &rsaquo; The web app</div>
35
- <h1 id="the-web-app">The web app</h1>
36
- <p>The Mapshaper web app at <a href="/">mapshaper.org</a> is designed for interactive editing and visual exploration. Its built-in console exposes the complete command set, so almost anything the CLI can do is available directly in the browser.</p>
37
- <p>All processing happens in your browser. Your data stays on your machine, even when you use the public website.</p>
38
- <h2 id="loading-data">Loading data</h2>
39
- <p>Drag-drop, paste, or use the <strong>Add files</strong> button to import data.</p>
40
- <p>A few less-obvious behaviors:</p>
41
- <ul>
42
- <li><strong>Drop a <code>.zip</code> containing a Shapefile bundle</strong> &mdash; Mapshaper unzips it on the fly and pulls out the sidecars. (Same goes for <code>.gz</code> for single-file formats and <code>.kmz</code> for KML.)</li>
43
- <li><strong>Paste a URL</strong> anywhere on the page to import the file at that address.</li>
44
- <li><strong>Query-string preload</strong> &mdash; <code>https://mapshaper.org/?files=URL1,URL2</code> imports a comma-separated list of URLs. All files need to be served from a host that allows cross-origin requests. Append <code>&amp;q</code> to skip the import dialog and open the files immediately.</li>
45
- <li><strong>With advanced options</strong> is a freeform text field. Anything you&#39;d pass after <code>-i</code> on the CLI works here, including <code>encoding=</code>, <code>string-fields=</code>, <code>csv-fields=</code>, <code>csv-filter=</code>, <code>combine-files</code>, <code>name=</code> and so on.</li>
46
- <li><strong>Multiple files do not auto-combine.</strong> Selecting several files at once imports them as independent layers. To get a shared topology (so common boundaries simplify identically), tick <strong>with advanced options</strong> and add <code>combine-files</code>.</li>
47
- </ul>
48
- <h3 id="tips-for-importing-shapefiles">Tips for importing Shapefiles</h3>
49
- <ul>
50
- <li>Drag-drop or select the <code>.shp</code>, <code>.dbf</code> and <code>.prj</code> files together. Without <code>.dbf</code> you&#39;ll have geometry but no attributes; without <code>.prj</code>, projection-dependent commands won&#39;t know what to do.</li>
51
- <li>If you see a warning about an unknown text encoding, re-import using the <strong>with advanced options</strong> checkbox and set <code>encoding=</code> (for example, <code>encoding=big5</code> for Big-5).</li>
52
- </ul>
53
- <h2 id="the-console">The console</h2>
54
- <p>The Console (top-right of the header, or <strong>space bar</strong> to toggle) is the most powerful part of the UI. Anything the <a href="/docs/reference.html">CLI</a> can do, you can do here.</p>
55
- <h3 id="keyboard">Keyboard</h3>
56
- <ul>
57
- <li><strong>Space</strong> &mdash; open or close the console (only when you&#39;re not typing in another text field).</li>
58
- <li><strong>Esc</strong> &mdash; close the console, or close any open panel.</li>
59
- <li><strong>Up / Down</strong> &mdash; cycle through previous commands. The history persists across page reloads.</li>
60
- <li><strong>Backslash <code>\</code> at end of line</strong> &mdash; continue a long command on the next line. The Enter key adds the wrap; another <strong>Enter</strong> runs the full command.</li>
61
- </ul>
62
- <h3 id="syntax">Syntax</h3>
63
- <ul>
64
- <li>The leading <code>-</code> is optional in the console: <code>clip places</code> works the same as <code>-clip places</code>.</li>
65
- <li>Commands run on the <strong>currently-selected layer</strong> by default. Switch layers in the layer panel before issuing a command, or pass <code>target=</code> to be explicit (<code>target=*</code> runs against every layer).</li>
66
- </ul>
67
- <h3 id="magic-words-at-the-prompt">Magic words at the prompt</h3>
68
- <p>These are recognized directly by the console, not by Mapshaper:</p>
69
- <ul>
70
- <li><code>history</code> &mdash; print the current session as a single command-line string. Handy for reproducing an interactive workflow as a script.</li>
71
- <li><code>layers</code> &mdash; print the list of loaded layers.</li>
72
- <li><code>clear</code> &mdash; clear the console buffer.</li>
73
- <li><code>close</code> / <code>exit</code> / <code>quit</code> &mdash; close the console.</li>
74
- </ul>
75
- <h3 id="discovering-commands">Discovering commands</h3>
76
- <ul>
77
- <li><code>help</code> lists every available command.</li>
78
- <li><code>help &lt;command&gt;</code> shows the full options for one command, e.g. <code>help dissolve</code>.</li>
79
- <li>The <a href="/docs/reference.html">command reference</a> is the same content with a search box.</li>
80
- </ul>
81
- <h2 id="the-map">The map</h2>
82
- <h3 id="right-click-menu">Right-click menu</h3>
83
- <p>The right-click menu adapts to what&#39;s under the cursor:</p>
84
- <ul>
85
- <li><strong>Copy lon, lat</strong> &mdash; copy the WGS84 coordinates of the click point to the clipboard.</li>
86
- <li><strong>Copy x, y</strong> &mdash; copy the projected coordinates of the click point.</li>
87
- <li><strong>Copy as GeoJSON</strong> &mdash; copy the selected feature(s) to the clipboard as GeoJSON. Useful for snipping out one polygon for use elsewhere.</li>
88
- <li><strong>Delete vertex</strong> / <strong>delete point</strong> / <strong>delete feature</strong> &mdash; available in the corresponding edit modes.</li>
89
- </ul>
90
- <h3 id="layer-navigation">Layer navigation</h3>
91
- <ul>
92
- <li><strong>Left / Right arrows</strong> (when not typing) &mdash; cycle through the loaded layers.</li>
93
- </ul>
94
- <h2 id="display-options">Display options</h2>
95
- <p>The <strong>Display</strong> button at the top right opens the display options panel.</p>
96
- <ul>
97
- <li><strong>Detect line intersections</strong> &mdash; highlights self-intersections in red as you simplify or edit. The quickest way to spot simplification damage. The setting is remembered between sessions.</li>
98
- </ul>
99
- <h2 id="snapshots-and-session-history">Snapshots and session history</h2>
100
- <p>The ribbon icon in the layer panel opens the snapshot menu. Snapshots save the current state of a session so you can return to it. They also record the <strong>session history</strong> that produced the snapshot, so when you re-open one the full history is available too.</p>
101
- <ul>
102
- <li><strong>Create a snapshot</strong> &mdash; saves to in-browser storage. These are session-scoped and <strong>deleted when the tab closes or the page is reloaded.</strong> For anything you want to keep, <strong>Save snapshot to file</strong> writes a <code>.msx</code> file you can re-open later.</li>
103
- <li><strong>View session history</strong> &mdash; a shortcut for typing <code>history</code> in the console: prints the full sequence of commands that produced the current state.</li>
104
- </ul>
105
- <p>See the <a href="/docs/formats/snapshot.html">Mapshaper snapshot format page</a> for more on what a <code>.msx</code> file contains and how to use it from the CLI.</p>
106
- <h2 id="running-the-web-ui-locally">Running the web UI locally</h2>
107
- <p><code>mapshaper-gui</code> (installed alongside <code>mapshaper</code> when you <code>npm install -g mapshaper</code>) starts a local Node web server and opens the web UI at <code>http://localhost:5555</code>. Use <code>--port</code> to pick a different port.</p>
108
- <p>You can pre-load files by listing them on the command line, which skips the import dialog:</p>
109
- <pre><code class="hljs language-bash">mapshaper-gui states.shp rivers.shp
110
- </code></pre>
111
- <h2 id="browser-support">Browser support</h2>
112
- <p>When importing very large files (hundreds of megabytes), the web app may run out of memory and crash. Firefox used to be better than Chrome at handling large files, but Chrome seems to have improved recently. If the web app crashes, try the <a href="/docs/essentials/command-line.html"><code>mapshaper-xl</code> command-line tool</a>, which can allocate a large amount of memory.</p>
113
- <h2 id="privacy">Privacy</h2>
114
- <p>The Mapshaper web app runs entirely in your browser. No file content is uploaded to any server. The only network traffic is for static assets (the app itself), basemap tiles when you&#39;ve enabled a basemap, and analytics for <code>mapshaper.org</code> page loads. See the <a href="/privacy.html">privacy policy</a> for details.</p>
115
-
116
- <div class="edit-link">
117
- <a href="https://github.com/mbloch/mapshaper/edit/master/docs/essentials/web-app.md">Edit this page on GitHub</a>
118
- </div>
119
- </article>
120
- </main>
121
-
122
- <aside class="docs-toc">
123
- <div class="docs-toc-title">On this page</div><ul><li class="lvl-2"><a href="#loading-data">Loading data</a></li><li class="lvl-3"><a href="#tips-for-importing-shapefiles">Tips for importing Shapefiles</a></li><li class="lvl-2"><a href="#the-console">The console</a></li><li class="lvl-3"><a href="#keyboard">Keyboard</a></li><li class="lvl-3"><a href="#syntax">Syntax</a></li><li class="lvl-3"><a href="#magic-words-at-the-prompt">Magic words at the prompt</a></li><li class="lvl-3"><a href="#discovering-commands">Discovering commands</a></li><li class="lvl-2"><a href="#the-map">The map</a></li><li class="lvl-3"><a href="#right-click-menu">Right-click menu</a></li><li class="lvl-3"><a href="#layer-navigation">Layer navigation</a></li><li class="lvl-2"><a href="#display-options">Display options</a></li><li class="lvl-2"><a href="#snapshots-and-session-history">Snapshots and session history</a></li><li class="lvl-2"><a href="#running-the-web-ui-locally">Running the web UI locally</a></li><li class="lvl-2"><a href="#browser-support">Browser support</a></li><li class="lvl-2"><a href="#privacy">Privacy</a></li></ul>
124
- </aside>
125
-
126
- </div>
127
-
128
- <script src="/docs/_assets/docs.js" defer></script>
129
-
130
- <footer class="docs-footer">
131
- <div class="docs-footer-inner">
132
- <span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
133
- <span><a href="/privacy.html">Privacy</a> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
134
- </div>
135
- </footer>
136
-
137
- </body>
138
- </html>
@@ -1,106 +0,0 @@
1
- ---
2
- title: The web app
3
- description: A tour of Mapshaper's web interface, including loading data, the console, the right-click menu, snapshots, browser support and running it locally.
4
- ---
5
-
6
- # The web app
7
-
8
- The Mapshaper web app at [mapshaper.org](/) is designed for interactive editing and visual exploration. Its built-in console exposes the complete command set, so almost anything the CLI can do is available directly in the browser.
9
-
10
- All processing happens in your browser. Your data stays on your machine, even when you use the public website.
11
-
12
- ## Loading data
13
-
14
- Drag-drop, paste, or use the **Add files** button to import data.
15
-
16
- A few less-obvious behaviors:
17
-
18
- - **Drop a `.zip` containing a Shapefile bundle** &mdash; Mapshaper unzips it on the fly and pulls out the sidecars. (Same goes for `.gz` for single-file formats and `.kmz` for KML.)
19
- - **Paste a URL** anywhere on the page to import the file at that address.
20
- - **Query-string preload** &mdash; `https://mapshaper.org/?files=URL1,URL2` imports a comma-separated list of URLs. All files need to be served from a host that allows cross-origin requests. Append `&q` to skip the import dialog and open the files immediately.
21
- - **With advanced options** is a freeform text field. Anything you'd pass after `-i` on the CLI works here, including `encoding=`, `string-fields=`, `csv-fields=`, `csv-filter=`, `combine-files`, `name=` and so on.
22
- - **Multiple files do not auto-combine.** Selecting several files at once imports them as independent layers. To get a shared topology (so common boundaries simplify identically), tick **with advanced options** and add `combine-files`.
23
-
24
- ### Tips for importing Shapefiles
25
-
26
- - Drag-drop or select the `.shp`, `.dbf` and `.prj` files together. Without `.dbf` you'll have geometry but no attributes; without `.prj`, projection-dependent commands won't know what to do.
27
- - If you see a warning about an unknown text encoding, re-import using the **with advanced options** checkbox and set `encoding=` (for example, `encoding=big5` for Big-5).
28
-
29
- ## The console
30
-
31
- The Console (top-right of the header, or **space bar** to toggle) is the most powerful part of the UI. Anything the [CLI](/docs/reference.html.md) can do, you can do here.
32
-
33
- ### Keyboard
34
-
35
- - **Space** &mdash; open or close the console (only when you're not typing in another text field).
36
- - **Esc** &mdash; close the console, or close any open panel.
37
- - **Up / Down** &mdash; cycle through previous commands. The history persists across page reloads.
38
- - **Backslash `\` at end of line** &mdash; continue a long command on the next line. The Enter key adds the wrap; another **Enter** runs the full command.
39
-
40
- ### Syntax
41
-
42
- - The leading `-` is optional in the console: `clip places` works the same as `-clip places`.
43
- - Commands run on the **currently-selected layer** by default. Switch layers in the layer panel before issuing a command, or pass `target=` to be explicit (`target=*` runs against every layer).
44
-
45
- ### Magic words at the prompt
46
-
47
- These are recognized directly by the console, not by Mapshaper:
48
-
49
- - `history` &mdash; print the current session as a single command-line string. Handy for reproducing an interactive workflow as a script.
50
- - `layers` &mdash; print the list of loaded layers.
51
- - `clear` &mdash; clear the console buffer.
52
- - `close` / `exit` / `quit` &mdash; close the console.
53
-
54
- ### Discovering commands
55
-
56
- - `help` lists every available command.
57
- - `help <command>` shows the full options for one command, e.g. `help dissolve`.
58
- - The [command reference](/docs/reference.html.md) is the same content with a search box.
59
-
60
- ## The map
61
-
62
- ### Right-click menu
63
-
64
- The right-click menu adapts to what's under the cursor:
65
-
66
- - **Copy lon, lat** &mdash; copy the WGS84 coordinates of the click point to the clipboard.
67
- - **Copy x, y** &mdash; copy the projected coordinates of the click point.
68
- - **Copy as GeoJSON** &mdash; copy the selected feature(s) to the clipboard as GeoJSON. Useful for snipping out one polygon for use elsewhere.
69
- - **Delete vertex** / **delete point** / **delete feature** &mdash; available in the corresponding edit modes.
70
-
71
- ### Layer navigation
72
-
73
- - **Left / Right arrows** (when not typing) &mdash; cycle through the loaded layers.
74
-
75
- ## Display options
76
-
77
- The **Display** button at the top right opens the display options panel.
78
-
79
- - **Detect line intersections** &mdash; highlights self-intersections in red as you simplify or edit. The quickest way to spot simplification damage. The setting is remembered between sessions.
80
-
81
- ## Snapshots and session history
82
-
83
- The ribbon icon in the layer panel opens the snapshot menu. Snapshots save the current state of a session so you can return to it. They also record the **session history** that produced the snapshot, so when you re-open one the full history is available too.
84
-
85
- - **Create a snapshot** &mdash; saves to in-browser storage. These are session-scoped and **deleted when the tab closes or the page is reloaded.** For anything you want to keep, **Save snapshot to file** writes a `.msx` file you can re-open later.
86
- - **View session history** &mdash; a shortcut for typing `history` in the console: prints the full sequence of commands that produced the current state.
87
-
88
- See the [Mapshaper snapshot format page](/docs/formats/snapshot.html.md) for more on what a `.msx` file contains and how to use it from the CLI.
89
-
90
- ## Running the web UI locally
91
-
92
- `mapshaper-gui` (installed alongside `mapshaper` when you `npm install -g mapshaper`) starts a local Node web server and opens the web UI at `http://localhost:5555`. Use `--port` to pick a different port.
93
-
94
- You can pre-load files by listing them on the command line, which skips the import dialog:
95
-
96
- ```bash
97
- mapshaper-gui states.shp rivers.shp
98
- ```
99
-
100
- ## Browser support
101
-
102
- When importing very large files (hundreds of megabytes), the web app may run out of memory and crash. Firefox used to be better than Chrome at handling large files, but Chrome seems to have improved recently. If the web app crashes, try the [`mapshaper-xl` command-line tool](/docs/essentials/command-line.html.md), which can allocate a large amount of memory.
103
-
104
- ## Privacy
105
-
106
- The Mapshaper web app runs entirely in your browser. No file content is uploaded to any server. The only network traffic is for static assets (the app itself), basemap tiles when you've enabled a basemap, and analytics for `mapshaper.org` page loads. See the [privacy policy](/privacy.html) for details.