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.
- package/LICENSE +1 -1
- package/bin/mapshaper-gui +31 -7
- package/mapshaper.js +45 -42
- package/package.json +8 -7
- package/www/geopackage.js +10 -10
- package/www/index.html +32 -4
- package/www/mapshaper-gui.js +529 -83
- package/www/mapshaper.js +45 -42
- package/www/modules.js +5 -5
- package/www/page.css +157 -0
- package/www/docs/_assets/cmd-search.js +0 -213
- package/www/docs/_assets/docs.css +0 -722
- package/www/docs/_assets/docs.js +0 -75
- package/www/docs/_assets/highlight.css +0 -10
- package/www/docs/essentials/command-line.html +0 -127
- package/www/docs/essentials/command-line.html.md +0 -112
- package/www/docs/essentials/web-app.html +0 -138
- package/www/docs/essentials/web-app.html.md +0 -106
- package/www/docs/examples/basics.html +0 -275
- package/www/docs/examples/basics.html.md +0 -370
- package/www/docs/examples/data/Makefile +0 -31
- package/www/docs/examples/data/globe.msx +0 -0
- package/www/docs/examples/data/globe.svg +0 -616
- package/www/docs/examples/data/globe.txt +0 -21
- package/www/docs/examples/data/globe.zip +0 -0
- package/www/docs/examples/data/ne_50m_admin_0_countries.geojson +0 -1
- package/www/docs/examples/data/ne_50m_admin_1_states_provinces_lakes.geojson +0 -1
- package/www/docs/examples/data/us-states.msx +0 -0
- package/www/docs/examples/data/us-states.svg +0 -56
- package/www/docs/examples/data/us-states.txt +0 -6
- package/www/docs/examples/data/us-states.zip +0 -0
- package/www/docs/examples/globe.html +0 -108
- package/www/docs/examples/globe.html.md +0 -64
- package/www/docs/examples/us-states.html +0 -88
- package/www/docs/examples/us-states.html.md +0 -44
- package/www/docs/formats/csv.html +0 -127
- package/www/docs/formats/csv.html.md +0 -97
- package/www/docs/formats/dbf.html +0 -87
- package/www/docs/formats/dbf.html.md +0 -39
- package/www/docs/formats/flatgeobuf.html +0 -85
- package/www/docs/formats/flatgeobuf.html.md +0 -41
- package/www/docs/formats/geojson.html +0 -107
- package/www/docs/formats/geojson.html.md +0 -65
- package/www/docs/formats/geopackage.html +0 -87
- package/www/docs/formats/geopackage.html.md +0 -42
- package/www/docs/formats/json.html +0 -83
- package/www/docs/formats/json.html.md +0 -35
- package/www/docs/formats/kml.html +0 -82
- package/www/docs/formats/kml.html.md +0 -39
- package/www/docs/formats/overview.html +0 -191
- package/www/docs/formats/overview.html.md +0 -34
- package/www/docs/formats/shapefile.html +0 -123
- package/www/docs/formats/shapefile.html.md +0 -84
- package/www/docs/formats/snapshot.html +0 -87
- package/www/docs/formats/snapshot.html.md +0 -39
- package/www/docs/formats/svg.html +0 -99
- package/www/docs/formats/svg.html.md +0 -51
- package/www/docs/formats/topojson.html +0 -102
- package/www/docs/formats/topojson.html.md +0 -54
- package/www/docs/gallery/index.html +0 -80
- package/www/docs/gallery/index.html.md +0 -29
- package/www/docs/guides/combining-layers.html +0 -109
- package/www/docs/guides/combining-layers.html.md +0 -89
- package/www/docs/guides/expressions.html +0 -600
- package/www/docs/guides/expressions.html.md +0 -376
- package/www/docs/guides/programmatic.html +0 -117
- package/www/docs/guides/programmatic.html.md +0 -91
- package/www/docs/guides/projections.html +0 -158
- package/www/docs/guides/projections.html.md +0 -118
- package/www/docs/guides/simplification.html +0 -110
- package/www/docs/guides/simplification.html.md +0 -96
- package/www/docs/guides/topology.html +0 -90
- package/www/docs/guides/topology.html.md +0 -63
- package/www/docs/images/cal-counties.png +0 -0
- package/www/docs/images/simplification-detail.png +0 -0
- package/www/docs/images/simplification-dp.png +0 -0
- package/www/docs/images/simplification-mod2.png +0 -0
- package/www/docs/images/tiger-counties.png +0 -0
- package/www/docs/index.html +0 -101
- package/www/docs/index.html.md +0 -59
- package/www/docs/reference.html +0 -1302
- package/www/docs/reference.html.md +0 -1817
- package/www/docs/whats-new.html +0 -77
- package/www/docs/whats-new.html.md +0 -59
- package/www/llms-full.txt +0 -4053
- package/www/llms.txt +0 -55
|
@@ -1,88 +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>U.S. States · mapshaper docs</title>
|
|
7
|
-
<meta name="description" content="Simple U.S. state map with random, non-adjacent colors">
|
|
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="is-example-map">
|
|
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'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">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" class="is-active">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> › Examples › U.S. state map</div>
|
|
35
|
-
<h1 id="us-state-map">U.S. state map</h1>
|
|
36
|
-
<p>Difficulty: easy</p>
|
|
37
|
-
<p><img src="/docs/examples/data/us-states.svg" alt="U.S. States"></p>
|
|
38
|
-
<h3 id="steps">Steps</h3>
|
|
39
|
-
<ol>
|
|
40
|
-
<li>Load state/province polygons (source: Natural Earth)</li>
|
|
41
|
-
<li>Keep only U.S. states</li>
|
|
42
|
-
<li>Project to the "Albers USA" projection</li>
|
|
43
|
-
<li>Assign random, non-adjacent colors</li>
|
|
44
|
-
<li>Export as SVG</li>
|
|
45
|
-
</ol>
|
|
46
|
-
<h3 id="code">Code</h3>
|
|
47
|
-
<pre><code class="hljs language-bash">mapshaper \
|
|
48
|
-
-i ne_50m_admin_1_states_provinces_lakes.geojson name=states \
|
|
49
|
-
-filter <span class="hljs-string">'admin == "United States of America"'</span> \
|
|
50
|
-
-proj albersusa \
|
|
51
|
-
-classify non-adjacent colors=Tableau10 \
|
|
52
|
-
-o us-states.svg height=400 width=600
|
|
53
|
-
</code></pre>
|
|
54
|
-
<h3 id="notes">Notes</h3>
|
|
55
|
-
<ul>
|
|
56
|
-
<li>To see the list of built-in color schemes to use with <code>-classify</code>, run <code>mapshaper -colors</code>. You can also use <code>colors=random</code>.</li>
|
|
57
|
-
<li>The Albers USA projection (<code>-proj albersusa</code>) is a custom projection used by The New York Times for U.S. maps.</li>
|
|
58
|
-
</ul>
|
|
59
|
-
<h3 id="assets">Assets</h3>
|
|
60
|
-
<ul>
|
|
61
|
-
<li><a href="https://mapshaper.org/?files=https%3A%2F%2Fmapshaper.org%2Fdocs%2Fexamples%2Fdata%2Fus-states.msx&q" data-open-snapshot="/docs/examples/data/us-states.msx">Open in the web app</a> — loads a snapshot file containing the finished map</li>
|
|
62
|
-
<li><a href="/docs/examples/data/us-states.msx">Download snapshot (<code>us-states.msx</code>)</a></li>
|
|
63
|
-
<li><a href="/docs/examples/data/us-states.zip">Download source data (<code>us-states.zip</code>)</a></li>
|
|
64
|
-
</ul>
|
|
65
|
-
|
|
66
|
-
<div class="edit-link">
|
|
67
|
-
<a href="https://github.com/mbloch/mapshaper/edit/master/docs/examples/us-states.md">Edit this page on GitHub</a>
|
|
68
|
-
</div>
|
|
69
|
-
</article>
|
|
70
|
-
</main>
|
|
71
|
-
|
|
72
|
-
<aside class="docs-toc">
|
|
73
|
-
<div class="docs-toc-title">On this page</div><ul><li class="lvl-3"><a href="#steps">Steps</a></li><li class="lvl-3"><a href="#code">Code</a></li><li class="lvl-3"><a href="#notes">Notes</a></li><li class="lvl-3"><a href="#assets">Assets</a></li></ul>
|
|
74
|
-
</aside>
|
|
75
|
-
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<script src="/docs/_assets/docs.js" defer></script>
|
|
79
|
-
|
|
80
|
-
<footer class="docs-footer">
|
|
81
|
-
<div class="docs-footer-inner">
|
|
82
|
-
<span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
|
|
83
|
-
<span><a href="/privacy.html">Privacy</a> · <a href="/terms.html">Terms</a> · <a href="/sponsor.html">Support mapshaper</a></span>
|
|
84
|
-
</div>
|
|
85
|
-
</footer>
|
|
86
|
-
|
|
87
|
-
</body>
|
|
88
|
-
</html>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: U.S. States
|
|
3
|
-
description: Simple U.S. state map with random, non-adjacent colors
|
|
4
|
-
recipe: us-states.txt
|
|
5
|
-
image: us-states.svg
|
|
6
|
-
snapshot: us-states.msx
|
|
7
|
-
download: us-states.zip
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# U.S. state map
|
|
11
|
-
|
|
12
|
-
Difficulty: easy
|
|
13
|
-
|
|
14
|
-

|
|
15
|
-
|
|
16
|
-
### Steps
|
|
17
|
-
|
|
18
|
-
1. Load state/province polygons (source: Natural Earth)
|
|
19
|
-
2. Keep only U.S. states
|
|
20
|
-
3. Project to the "Albers USA" projection
|
|
21
|
-
4. Assign random, non-adjacent colors
|
|
22
|
-
5. Export as SVG
|
|
23
|
-
|
|
24
|
-
### Code
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
mapshaper \
|
|
28
|
-
-i ne_50m_admin_1_states_provinces_lakes.geojson name=states \
|
|
29
|
-
-filter 'admin == "United States of America"' \
|
|
30
|
-
-proj albersusa \
|
|
31
|
-
-classify non-adjacent colors=Tableau10 \
|
|
32
|
-
-o us-states.svg height=400 width=600
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Notes
|
|
36
|
-
|
|
37
|
-
* To see the list of built-in color schemes to use with `-classify`, run `mapshaper -colors`. You can also use `colors=random`.
|
|
38
|
-
* The Albers USA projection (`-proj albersusa`) is a custom projection used by The New York Times for U.S. maps.
|
|
39
|
-
|
|
40
|
-
### Assets
|
|
41
|
-
|
|
42
|
-
- <a href="https://mapshaper.org/?files=https%3A%2F%2Fmapshaper.org%2Fdocs%2Fexamples%2Fdata%2Fus-states.msx&q" data-open-snapshot="/docs/examples/data/us-states.msx">Open in the web app</a> — loads a snapshot file containing the finished map
|
|
43
|
-
- [Download snapshot (`us-states.msx`)](/docs/examples/data/us-states.msx)
|
|
44
|
-
- [Download source data (`us-states.zip`)](/docs/examples/data/us-states.zip)
|
|
@@ -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>CSV and TSV · mapshaper docs</title>
|
|
7
|
-
<meta name="description" content="How Mapshaper reads and writes CSV/TSV, including encoding, type hints and large-file handling.">
|
|
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'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">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" class="is-active">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> › Formats › CSV / TSV</div>
|
|
35
|
-
<h1 id="csv-and-tsv">CSV and TSV</h1>
|
|
36
|
-
<p>Plain-text tabular data. Mapshaper treats CSV/TSV as pure attribute data by default, or as a point layer when longitude and latitude columns are present. Combined with <a href="/docs/reference.html#-join"><code>-join</code></a>, CSV is the lowest-friction way to attach external attributes (population, election results, anything keyed on a stable id) to a geometry layer.</p>
|
|
37
|
-
<p><strong>File extensions:</strong> <code>.csv</code>, <code>.tsv</code> · <strong>Read:</strong> ✓ · <strong>Write:</strong> ✓ · <strong>Multi-layer:</strong> no</p>
|
|
38
|
-
<h3 id="cli-examples">CLI examples</h3>
|
|
39
|
-
<pre><code class="hljs language-bash">mapshaper data.csv -info
|
|
40
|
-
mapshaper data.csv -points x=lon y=lat -o points.geojson
|
|
41
|
-
mapshaper big.csv csv-fields=<span class="hljs-built_in">id</span>,name,pop -info
|
|
42
|
-
mapshaper provinces.shp -drop-table -o stats.csv
|
|
43
|
-
mapshaper data.csv -o delimiter=<span class="hljs-string">";"</span> out.csv
|
|
44
|
-
</code></pre>
|
|
45
|
-
<h3 id="format-specific-input-options">Format-specific input options</h3>
|
|
46
|
-
<ul>
|
|
47
|
-
<li><code>encoding=</code> — text encoding. Default is UTF-8.</li>
|
|
48
|
-
<li><code>string-fields=</code> — comma-separated list of fields to import as strings even if their values look numeric. Use <code>string-fields=*</code> to import every field as a string. Essential for ZIP codes, FIPS codes and anything else where leading zeros matter.</li>
|
|
49
|
-
<li><code>field-types=</code> — per-field type hints, e.g. <code>FIPS:str,population:num</code>. More flexible alternative to <code>string-fields=</code>.</li>
|
|
50
|
-
<li><code>csv-skip-lines=</code> — skip N lines at the top of the file. Useful for spreadsheet exports with notes above the data.</li>
|
|
51
|
-
<li><code>csv-lines=</code> — import only the first N data rows.</li>
|
|
52
|
-
<li><code>csv-field-names=</code> — assign explicit field names. Combine with <code>csv-skip-lines=1</code> to override existing headers.</li>
|
|
53
|
-
<li><code>csv-fields=</code> — import only the named columns. Filtering happens during the read, so this option dramatically reduces peak memory for wide CSVs.</li>
|
|
54
|
-
<li><code>csv-filter=</code> — a JavaScript expression evaluated per row. Rows that return false are dropped before they ever reach the layer.</li>
|
|
55
|
-
<li><code>csv-dedup-fields</code> — rename duplicate column headers (otherwise Mapshaper errors out).</li>
|
|
56
|
-
<li><code>decimal-comma</code> — parse numbers using <code>1.000,01</code> European convention instead of <code>1,000.01</code>.</li>
|
|
57
|
-
</ul>
|
|
58
|
-
<h3 id="format-specific-output-options">Format-specific output options</h3>
|
|
59
|
-
<ul>
|
|
60
|
-
<li><code>encoding=</code> — text encoding for the output. Default is UTF-8.</li>
|
|
61
|
-
<li><code>delimiter=</code> — override the field delimiter, e.g. <code>delimiter="|"</code>.</li>
|
|
62
|
-
<li><code>decimal-comma</code> — emit numbers using the European decimal-comma convention.</li>
|
|
63
|
-
<li><code>field-order=ascending</code> — sort columns alphabetically.</li>
|
|
64
|
-
</ul>
|
|
65
|
-
<h3 id="practical-notes">Practical notes</h3>
|
|
66
|
-
<ul>
|
|
67
|
-
<li>The delimiter is auto-detected from the extension (<code>.csv</code> → comma, <code>.tsv</code> → tab). Use <code>-i format=csv</code> to force CSV parsing for a differently-named file (e.g. <code>.txt</code>).</li>
|
|
68
|
-
<li>When exporting non-point geometry to CSV, Mapshaper writes only the attribute table. Use <a href="/docs/reference.html#-points"><code>-points</code></a> first if you want to export point coordinates as <code>lon</code>/<code>lat</code> columns.</li>
|
|
69
|
-
<li>BOM-prefixed files (typically from Excel) are handled transparently on read.</li>
|
|
70
|
-
<li>Output has no quoting unless a value contains the delimiter, a quote or a newline.</li>
|
|
71
|
-
</ul>
|
|
72
|
-
<h3 id="importing-identifier-like-fields-zip-fips-phone-numbers-hellip">Importing identifier-like fields (ZIP, FIPS, phone numbers…)</h3>
|
|
73
|
-
<p>This is the single biggest CSV footgun. Mapshaper guesses each column's type from its values, so a column of US ZIP codes like <code>02134</code>, <code>90210</code>, <code>10001</code> looks numeric and gets imported as numbers — silently stripping leading zeros and breaking any subsequent join. The same applies to FIPS codes, phone numbers, account numbers and any other identifier that happens to contain only digits.</p>
|
|
74
|
-
<p>Always declare these columns as strings on import:</p>
|
|
75
|
-
<pre><code class="hljs language-bash">mapshaper -i counties.csv string-fields=GEOID,STATEFP,COUNTYFP -info
|
|
76
|
-
mapshaper -i zips.csv string-fields=zipcode -<span class="hljs-built_in">join</span> points key=zipcode,zipcode
|
|
77
|
-
</code></pre>
|
|
78
|
-
<p>If you don't trust the schema at all, <code>string-fields=*</code> imports every column as a string. You can also be precise with <code>field-types=</code>:</p>
|
|
79
|
-
<pre><code class="hljs language-bash">mapshaper -i data.csv field-types=GEOID:str,population:num,year:str -info
|
|
80
|
-
</code></pre>
|
|
81
|
-
<p>A symptom of getting this wrong is a join silently dropping all rows because <code>02134</code> (string) doesn't match <code>2134</code> (number).</p>
|
|
82
|
-
<h3 id="prefiltering-large-csvs">Prefiltering large CSVs</h3>
|
|
83
|
-
<p>For multi-gigabyte CSVs — election precinct records, OSM extract attribute tables, parcel data — it usually isn't viable to load the whole file into memory and then filter. Mapshaper has two options that filter <strong>during</strong> the read, before the data lands in a layer:</p>
|
|
84
|
-
<ul>
|
|
85
|
-
<li><code>csv-fields=</code> — keep only the named columns. Wide CSVs (hundreds of columns, only a few of interest) shrink dramatically.</li>
|
|
86
|
-
<li><code>csv-filter=</code> — a JavaScript expression evaluated per row. Rows that return false are skipped.</li>
|
|
87
|
-
</ul>
|
|
88
|
-
<p>Example (note that numerical fields have not been converted from strings at this point):</p>
|
|
89
|
-
<pre><code class="hljs language-bash">mapshaper -i big.csv \
|
|
90
|
-
csv-fields=GEOID,name,population,state \
|
|
91
|
-
csv-filter=<span class="hljs-string">'state == "TX" && population > "10000"'</span> \
|
|
92
|
-
-o cities-tx.csv
|
|
93
|
-
</code></pre>
|
|
94
|
-
<h3 id="in-the-web-app">In the web app</h3>
|
|
95
|
-
<p>The same import options work in the <a href="/docs/essentials/web-app.html">web app</a>. Tick <strong>with advanced options</strong> in the import dialog and pass any of <code>string-fields=</code>, <code>field-types=</code>, <code>encoding=</code>, <code>csv-fields=</code>, <code>csv-filter=</code> etc. as you would on the CLI:</p>
|
|
96
|
-
<pre><code>string-fields=GEOID,STATEFP encoding=utf8
|
|
97
|
-
</code></pre>
|
|
98
|
-
<p>For very large CSVs, <code>csv-fields=</code> and <code>csv-filter=</code> are the most useful options for keeping memory under control. If a file is too big for the browser to load, the <a href="/docs/essentials/command-line.html"><code>mapshaper-xl</code> CLI</a> is the fallback.</p>
|
|
99
|
-
<h2 id="external-resources">External resources</h2>
|
|
100
|
-
<ul>
|
|
101
|
-
<li><a href="https://datatracker.ietf.org/doc/html/rfc4180">RFC 4180: Common Format and MIME Type for CSV</a> — the closest thing to a CSV specification, though many real-world files diverge from it.</li>
|
|
102
|
-
<li><a href="https://specs.frictionlessdata.io/csv-dialect/">Frictionless CSV Dialect spec</a> — a practical schema for declaring how a particular CSV file is formatted (delimiter, quoting, line terminator).</li>
|
|
103
|
-
</ul>
|
|
104
|
-
|
|
105
|
-
<div class="edit-link">
|
|
106
|
-
<a href="https://github.com/mbloch/mapshaper/edit/master/docs/formats/csv.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-3"><a href="#cli-examples">CLI examples</a></li><li class="lvl-3"><a href="#format-specific-input-options">Format-specific input options</a></li><li class="lvl-3"><a href="#format-specific-output-options">Format-specific output options</a></li><li class="lvl-3"><a href="#practical-notes">Practical notes</a></li><li class="lvl-3"><a href="#importing-identifier-like-fields-zip-fips-phone-numbers-hellip">Importing identifier-like fields (ZIP, FIPS, phone numbers&hellip;)</a></li><li class="lvl-3"><a href="#prefiltering-large-csvs">Prefiltering large CSVs</a></li><li class="lvl-3"><a href="#in-the-web-app">In the web app</a></li><li class="lvl-2"><a href="#external-resources">External resources</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> · <a href="/terms.html">Terms</a> · <a href="/sponsor.html">Support mapshaper</a></span>
|
|
123
|
-
</div>
|
|
124
|
-
</footer>
|
|
125
|
-
|
|
126
|
-
</body>
|
|
127
|
-
</html>
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: CSV and TSV
|
|
3
|
-
description: How Mapshaper reads and writes CSV/TSV, including encoding, type hints and large-file handling.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# CSV and TSV
|
|
7
|
-
|
|
8
|
-
Plain-text tabular data. Mapshaper treats CSV/TSV as pure attribute data by default, or as a point layer when longitude and latitude columns are present. Combined with [`-join`](/docs/reference.html.md#-join), CSV is the lowest-friction way to attach external attributes (population, election results, anything keyed on a stable id) to a geometry layer.
|
|
9
|
-
|
|
10
|
-
**File extensions:** `.csv`, `.tsv` · **Read:** ✓ · **Write:** ✓ · **Multi-layer:** no
|
|
11
|
-
|
|
12
|
-
### CLI examples
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
mapshaper data.csv -info
|
|
16
|
-
mapshaper data.csv -points x=lon y=lat -o points.geojson
|
|
17
|
-
mapshaper big.csv csv-fields=id,name,pop -info
|
|
18
|
-
mapshaper provinces.shp -drop-table -o stats.csv
|
|
19
|
-
mapshaper data.csv -o delimiter=";" out.csv
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Format-specific input options
|
|
23
|
-
|
|
24
|
-
- `encoding=` — text encoding. Default is UTF-8.
|
|
25
|
-
- `string-fields=` — comma-separated list of fields to import as strings even if their values look numeric. Use `string-fields=*` to import every field as a string. Essential for ZIP codes, FIPS codes and anything else where leading zeros matter.
|
|
26
|
-
- `field-types=` — per-field type hints, e.g. `FIPS:str,population:num`. More flexible alternative to `string-fields=`.
|
|
27
|
-
- `csv-skip-lines=` — skip N lines at the top of the file. Useful for spreadsheet exports with notes above the data.
|
|
28
|
-
- `csv-lines=` — import only the first N data rows.
|
|
29
|
-
- `csv-field-names=` — assign explicit field names. Combine with `csv-skip-lines=1` to override existing headers.
|
|
30
|
-
- `csv-fields=` — import only the named columns. Filtering happens during the read, so this option dramatically reduces peak memory for wide CSVs.
|
|
31
|
-
- `csv-filter=` — a JavaScript expression evaluated per row. Rows that return false are dropped before they ever reach the layer.
|
|
32
|
-
- `csv-dedup-fields` — rename duplicate column headers (otherwise Mapshaper errors out).
|
|
33
|
-
- `decimal-comma` — parse numbers using `1.000,01` European convention instead of `1,000.01`.
|
|
34
|
-
|
|
35
|
-
### Format-specific output options
|
|
36
|
-
|
|
37
|
-
- `encoding=` — text encoding for the output. Default is UTF-8.
|
|
38
|
-
- `delimiter=` — override the field delimiter, e.g. `delimiter="|"`.
|
|
39
|
-
- `decimal-comma` — emit numbers using the European decimal-comma convention.
|
|
40
|
-
- `field-order=ascending` — sort columns alphabetically.
|
|
41
|
-
|
|
42
|
-
### Practical notes
|
|
43
|
-
|
|
44
|
-
- The delimiter is auto-detected from the extension (`.csv` → comma, `.tsv` → tab). Use `-i format=csv` to force CSV parsing for a differently-named file (e.g. `.txt`).
|
|
45
|
-
- When exporting non-point geometry to CSV, Mapshaper writes only the attribute table. Use [`-points`](/docs/reference.html.md#-points) first if you want to export point coordinates as `lon`/`lat` columns.
|
|
46
|
-
- BOM-prefixed files (typically from Excel) are handled transparently on read.
|
|
47
|
-
- Output has no quoting unless a value contains the delimiter, a quote or a newline.
|
|
48
|
-
|
|
49
|
-
### Importing identifier-like fields (ZIP, FIPS, phone numbers…)
|
|
50
|
-
|
|
51
|
-
This is the single biggest CSV footgun. Mapshaper guesses each column's type from its values, so a column of US ZIP codes like `02134`, `90210`, `10001` looks numeric and gets imported as numbers — silently stripping leading zeros and breaking any subsequent join. The same applies to FIPS codes, phone numbers, account numbers and any other identifier that happens to contain only digits.
|
|
52
|
-
|
|
53
|
-
Always declare these columns as strings on import:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
mapshaper -i counties.csv string-fields=GEOID,STATEFP,COUNTYFP -info
|
|
57
|
-
mapshaper -i zips.csv string-fields=zipcode -join points key=zipcode,zipcode
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
If you don't trust the schema at all, `string-fields=*` imports every column as a string. You can also be precise with `field-types=`:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
mapshaper -i data.csv field-types=GEOID:str,population:num,year:str -info
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
A symptom of getting this wrong is a join silently dropping all rows because `02134` (string) doesn't match `2134` (number).
|
|
67
|
-
|
|
68
|
-
### Prefiltering large CSVs
|
|
69
|
-
|
|
70
|
-
For multi-gigabyte CSVs — election precinct records, OSM extract attribute tables, parcel data — it usually isn't viable to load the whole file into memory and then filter. Mapshaper has two options that filter **during** the read, before the data lands in a layer:
|
|
71
|
-
|
|
72
|
-
- `csv-fields=` — keep only the named columns. Wide CSVs (hundreds of columns, only a few of interest) shrink dramatically.
|
|
73
|
-
- `csv-filter=` — a JavaScript expression evaluated per row. Rows that return false are skipped.
|
|
74
|
-
|
|
75
|
-
Example (note that numerical fields have not been converted from strings at this point):
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
mapshaper -i big.csv \
|
|
79
|
-
csv-fields=GEOID,name,population,state \
|
|
80
|
-
csv-filter='state == "TX" && population > "10000"' \
|
|
81
|
-
-o cities-tx.csv
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### In the web app
|
|
85
|
-
|
|
86
|
-
The same import options work in the [web app](/docs/essentials/web-app.html.md). Tick **with advanced options** in the import dialog and pass any of `string-fields=`, `field-types=`, `encoding=`, `csv-fields=`, `csv-filter=` etc. as you would on the CLI:
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
string-fields=GEOID,STATEFP encoding=utf8
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
For very large CSVs, `csv-fields=` and `csv-filter=` are the most useful options for keeping memory under control. If a file is too big for the browser to load, the [`mapshaper-xl` CLI](/docs/essentials/command-line.html.md) is the fallback.
|
|
93
|
-
|
|
94
|
-
## External resources
|
|
95
|
-
|
|
96
|
-
- [RFC 4180: Common Format and MIME Type for CSV](https://datatracker.ietf.org/doc/html/rfc4180) — the closest thing to a CSV specification, though many real-world files diverge from it.
|
|
97
|
-
- [Frictionless CSV Dialect spec](https://specs.frictionlessdata.io/csv-dialect/) — a practical schema for declaring how a particular CSV file is formatted (delimiter, quoting, line terminator).
|
|
@@ -1,87 +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>DBF · mapshaper docs</title>
|
|
7
|
-
<meta name="description" content="How Mapshaper reads and writes standalone DBF files, the tabular component of Shapefile.">
|
|
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'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">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" class="is-active">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> › Formats › DBF</div>
|
|
35
|
-
<h1 id="dbf">DBF</h1>
|
|
36
|
-
<p>DBF is the dBase database format. It's best known as the attribute-table half of a Shapefile, but Mapshaper can also import a <code>.dbf</code> on its own as a tabular layer with no geometry. <a href="/docs/formats/csv.html">CSV</a> is generally preferred as an exchange format for tabular data.</p>
|
|
37
|
-
<p><strong>File extension:</strong> <code>.dbf</code> · <strong>Read:</strong> ✓ · <strong>Write:</strong> ✓ · <strong>Geometry:</strong> none</p>
|
|
38
|
-
<h3 id="cli-examples">CLI examples</h3>
|
|
39
|
-
<pre><code class="hljs language-bash">mapshaper provinces.dbf -info
|
|
40
|
-
mapshaper provinces.dbf -filter <span class="hljs-string">'"BC,AB,SK".indexOf(prov) > -1'</span> -o subset.csv
|
|
41
|
-
mapshaper data.csv -o data.dbf
|
|
42
|
-
</code></pre>
|
|
43
|
-
<h3 id="format-specific-input-options">Format-specific input options</h3>
|
|
44
|
-
<ul>
|
|
45
|
-
<li><code>encoding=</code> — text encoding. If omitted, Mapshaper auto-detects, falling back to a <code>.cpg</code> sidecar file if present. Run <code>mapshaper -encodings</code> for the list of supported encodings.</li>
|
|
46
|
-
</ul>
|
|
47
|
-
<h3 id="format-specific-output-options">Format-specific output options</h3>
|
|
48
|
-
<ul>
|
|
49
|
-
<li><code>encoding=</code> — output text encoding. Default UTF-8 (with a matching <code>.cpg</code> sidecar).</li>
|
|
50
|
-
<li><code>field-order=ascending</code> — sort columns alphabetically.</li>
|
|
51
|
-
</ul>
|
|
52
|
-
<h3 id="practical-notes">Practical notes</h3>
|
|
53
|
-
<ul>
|
|
54
|
-
<li>DBF holds tabular data only — no geometry.</li>
|
|
55
|
-
<li>DBF files do not declare their text encoding internally. Mapshaper auto-detects against UTF-8, Windows-1252 and a few other common encodings. See the <a href="/docs/formats/shapefile.html#dbf-text-encoding">Shapefile encoding notes</a> for the full picture.</li>
|
|
56
|
-
<li>Field names are limited to 10 ASCII characters. Longer names are truncated on write; duplicate truncated names are disambiguated with numeric suffixes.</li>
|
|
57
|
-
<li>Field values are limited to 254 characters; longer strings will have been truncated when the file was written.</li>
|
|
58
|
-
</ul>
|
|
59
|
-
<h2 id="external-resources">External resources</h2>
|
|
60
|
-
<ul>
|
|
61
|
-
<li><a href="https://en.wikipedia.org/wiki/.dbf">Wikipedia: .dbf</a> — useful overview of the format's history and dialects.</li>
|
|
62
|
-
<li><a href="https://www.clicketyclick.dk/databases/xbase/format/">Xbase File Format Description</a> — Erik Bachmann's reference for the dBase / xBase family. The standard external citation for byte-level DBF details.</li>
|
|
63
|
-
</ul>
|
|
64
|
-
|
|
65
|
-
<div class="edit-link">
|
|
66
|
-
<a href="https://github.com/mbloch/mapshaper/edit/master/docs/formats/dbf.md">Edit this page on GitHub</a>
|
|
67
|
-
</div>
|
|
68
|
-
</article>
|
|
69
|
-
</main>
|
|
70
|
-
|
|
71
|
-
<aside class="docs-toc">
|
|
72
|
-
<div class="docs-toc-title">On this page</div><ul><li class="lvl-3"><a href="#cli-examples">CLI examples</a></li><li class="lvl-3"><a href="#format-specific-input-options">Format-specific input options</a></li><li class="lvl-3"><a href="#format-specific-output-options">Format-specific output options</a></li><li class="lvl-3"><a href="#practical-notes">Practical notes</a></li><li class="lvl-2"><a href="#external-resources">External resources</a></li></ul>
|
|
73
|
-
</aside>
|
|
74
|
-
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
<script src="/docs/_assets/docs.js" defer></script>
|
|
78
|
-
|
|
79
|
-
<footer class="docs-footer">
|
|
80
|
-
<div class="docs-footer-inner">
|
|
81
|
-
<span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
|
|
82
|
-
<span><a href="/privacy.html">Privacy</a> · <a href="/terms.html">Terms</a> · <a href="/sponsor.html">Support mapshaper</a></span>
|
|
83
|
-
</div>
|
|
84
|
-
</footer>
|
|
85
|
-
|
|
86
|
-
</body>
|
|
87
|
-
</html>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: DBF
|
|
3
|
-
description: How Mapshaper reads and writes standalone DBF files, the tabular component of Shapefile.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# DBF
|
|
7
|
-
|
|
8
|
-
DBF is the dBase database format. It's best known as the attribute-table half of a Shapefile, but Mapshaper can also import a `.dbf` on its own as a tabular layer with no geometry. [CSV](/docs/formats/csv.html.md) is generally preferred as an exchange format for tabular data.
|
|
9
|
-
|
|
10
|
-
**File extension:** `.dbf` · **Read:** ✓ · **Write:** ✓ · **Geometry:** none
|
|
11
|
-
|
|
12
|
-
### CLI examples
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
mapshaper provinces.dbf -info
|
|
16
|
-
mapshaper provinces.dbf -filter '"BC,AB,SK".indexOf(prov) > -1' -o subset.csv
|
|
17
|
-
mapshaper data.csv -o data.dbf
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Format-specific input options
|
|
21
|
-
|
|
22
|
-
- `encoding=` — text encoding. If omitted, Mapshaper auto-detects, falling back to a `.cpg` sidecar file if present. Run `mapshaper -encodings` for the list of supported encodings.
|
|
23
|
-
|
|
24
|
-
### Format-specific output options
|
|
25
|
-
|
|
26
|
-
- `encoding=` — output text encoding. Default UTF-8 (with a matching `.cpg` sidecar).
|
|
27
|
-
- `field-order=ascending` — sort columns alphabetically.
|
|
28
|
-
|
|
29
|
-
### Practical notes
|
|
30
|
-
|
|
31
|
-
- DBF holds tabular data only — no geometry.
|
|
32
|
-
- DBF files do not declare their text encoding internally. Mapshaper auto-detects against UTF-8, Windows-1252 and a few other common encodings. See the [Shapefile encoding notes](/docs/formats/shapefile.html.md#dbf-text-encoding) for the full picture.
|
|
33
|
-
- Field names are limited to 10 ASCII characters. Longer names are truncated on write; duplicate truncated names are disambiguated with numeric suffixes.
|
|
34
|
-
- Field values are limited to 254 characters; longer strings will have been truncated when the file was written.
|
|
35
|
-
|
|
36
|
-
## External resources
|
|
37
|
-
|
|
38
|
-
- [Wikipedia: .dbf](https://en.wikipedia.org/wiki/.dbf) — useful overview of the format's history and dialects.
|
|
39
|
-
- [Xbase File Format Description](https://www.clicketyclick.dk/databases/xbase/format/) — Erik Bachmann's reference for the dBase / xBase family. The standard external citation for byte-level DBF details.
|
|
@@ -1,85 +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>FlatGeobuf · mapshaper docs</title>
|
|
7
|
-
<meta name="description" content="How Mapshaper reads and writes FlatGeobuf (.fgb), a streamable binary vector format.">
|
|
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'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">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" class="is-active">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> › Formats › FlatGeobuf</div>
|
|
35
|
-
<h1 id="flatgeobuf">FlatGeobuf</h1>
|
|
36
|
-
<p>FlatGeobuf is a modern binary vector format designed for fast streaming reads. A single self-contained file with UTF-8 text encoding, it avoids the companion-file clutter of Shapefile. Its optional embedded spatial index enables efficient bounding-box queries without reading the whole file, making it well-suited to large datasets served over HTTP. It also works well as a general-purpose GIS exchange format.</p>
|
|
37
|
-
<p><strong>File extension:</strong> <code>.fgb</code> · <strong>Read:</strong> ✓ · <strong>Write:</strong> ✓ · <strong>Multi-layer:</strong> no (one layer per file)</p>
|
|
38
|
-
<h3 id="cli-examples">CLI examples</h3>
|
|
39
|
-
<pre><code class="hljs language-bash">mapshaper buildings.fgb -info
|
|
40
|
-
mapshaper buildings.fgb -simplify 5% -o buildings.geojson
|
|
41
|
-
mapshaper provinces.shp -o provinces.fgb
|
|
42
|
-
</code></pre>
|
|
43
|
-
<h3 id="format-specific-input-options">Format-specific input options</h3>
|
|
44
|
-
<p>There are no FlatGeobuf-specific <code>-i</code> options.</p>
|
|
45
|
-
<h3 id="format-specific-output-options">Format-specific output options</h3>
|
|
46
|
-
<p>There are no FlatGeobuf-specific <code>-o</code> options. The format honors the general flags (<code>precision=</code>, <code>gzip</code>, <code>zip</code>, etc.) where they apply.</p>
|
|
47
|
-
<h3 id="practical-notes">Practical notes</h3>
|
|
48
|
-
<ul>
|
|
49
|
-
<li>Mapshaper reads CRS metadata from the file header when it's encoded as an EPSG code. WKT2-only definitions can't be parsed and produce an "Unable to import WKT2 CRS from FlatGeobuf" warning — the layer comes in without a CRS.</li>
|
|
50
|
-
<li>On output, Mapshaper embeds an EPSG code in the FlatGeobuf header whenever it can derive one from the source: a round-tripped FlatGeobuf or GeoPackage CRS, an <code>epsg:NNNN</code> string passed to <code>-proj</code>, an <code>AUTHORITY["EPSG", N]</code> clause in a Shapefile <code>.prj</code>, or any encoding of WGS-84 or Web Mercator (which covers most GeoJSON, CSV-with-lat/lon and <code>-proj wgs84</code>/<code>-proj webmercator</code> outputs).</li>
|
|
51
|
-
<li>Mapshaper cannot yet convert an arbitrary proj4 definition (such as a custom Albers projection set with <code>-proj +proj=aea ...</code>) to an EPSG code. In that case the file is written with no CRS in the header and a warning is printed: <em>"Wrote <code>foo.fgb</code> without a CRS in the FlatGeobuf header..."</em>. Re-run the file through <code>ogr2ogr</code> if you need the CRS embedded for downstream tools.</li>
|
|
52
|
-
<li>Mapshaper does not write the optional packed R-tree spatial index, and it doesn't use the index for selective reads of indexed input either — the whole file is read into memory. If you need an indexed <code>.fgb</code> for HTTP range-request reads, build it with <code>ogr2ogr</code> or the <a href="https://github.com/flatgeobuf/flatgeobuf"><code>flatgeobuf</code> CLI</a>.</li>
|
|
53
|
-
</ul>
|
|
54
|
-
<h2 id="external-resources">External resources</h2>
|
|
55
|
-
<ul>
|
|
56
|
-
<li><a href="https://flatgeobuf.org/">flatgeobuf.org</a> — project home with spec links and language bindings.</li>
|
|
57
|
-
<li><a href="https://worace.works/2022/02/23/kicking-the-tires-flatgeobuf/">Kicking the Tires: FlatGeobuf</a> — an independent practical writeup with benchmarks against Shapefile, GeoJSON and GeoPackage.</li>
|
|
58
|
-
<li><a href="https://brycemecum.com/2022/04/04/flatgeobuf/">Bryce Mecum: Flatgeobuf</a> — a hands-on exploration of streaming reads in the browser, including a worth-knowing gotcha about the spatial index sitting at the front of the file.</li>
|
|
59
|
-
<li><a href="https://guide.cloudnativegeo.org/flatgeobuf/">Cloud-Native Geospatial Formats Guide: FlatGeobuf</a> — how the format fits into modern cloud-storage workflows.</li>
|
|
60
|
-
<li>FlatGeobuf reading and writing in Mapshaper is built on the official <a href="https://github.com/flatgeobuf/flatgeobuf"><code>flatgeobuf</code></a> JavaScript library, which provides the FlatBuffers schema, header parsing and feature serialisation primitives.</li>
|
|
61
|
-
</ul>
|
|
62
|
-
|
|
63
|
-
<div class="edit-link">
|
|
64
|
-
<a href="https://github.com/mbloch/mapshaper/edit/master/docs/formats/flatgeobuf.md">Edit this page on GitHub</a>
|
|
65
|
-
</div>
|
|
66
|
-
</article>
|
|
67
|
-
</main>
|
|
68
|
-
|
|
69
|
-
<aside class="docs-toc">
|
|
70
|
-
<div class="docs-toc-title">On this page</div><ul><li class="lvl-3"><a href="#cli-examples">CLI examples</a></li><li class="lvl-3"><a href="#format-specific-input-options">Format-specific input options</a></li><li class="lvl-3"><a href="#format-specific-output-options">Format-specific output options</a></li><li class="lvl-3"><a href="#practical-notes">Practical notes</a></li><li class="lvl-2"><a href="#external-resources">External resources</a></li></ul>
|
|
71
|
-
</aside>
|
|
72
|
-
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
<script src="/docs/_assets/docs.js" defer></script>
|
|
76
|
-
|
|
77
|
-
<footer class="docs-footer">
|
|
78
|
-
<div class="docs-footer-inner">
|
|
79
|
-
<span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
|
|
80
|
-
<span><a href="/privacy.html">Privacy</a> · <a href="/terms.html">Terms</a> · <a href="/sponsor.html">Support mapshaper</a></span>
|
|
81
|
-
</div>
|
|
82
|
-
</footer>
|
|
83
|
-
|
|
84
|
-
</body>
|
|
85
|
-
</html>
|