mapshaper 0.6.121 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +5 -3
  2. package/mapshaper.js +1342 -275
  3. package/package.json +5 -2
  4. package/www/assets/jetbrains-mono-regular.woff2 +0 -0
  5. package/www/assets/static-page.css +179 -0
  6. package/www/docs/_assets/cmd-search.js +213 -0
  7. package/www/docs/_assets/docs.css +712 -0
  8. package/www/docs/_assets/docs.js +75 -0
  9. package/www/docs/_assets/highlight.css +10 -0
  10. package/www/docs/essentials/command-line.html +127 -0
  11. package/www/docs/essentials/command-line.html.md +112 -0
  12. package/www/docs/essentials/web-app.html +138 -0
  13. package/www/docs/essentials/web-app.html.md +106 -0
  14. package/www/docs/examples/basics.html +276 -0
  15. package/www/docs/examples/basics.html.md +371 -0
  16. package/www/docs/examples/data/Makefile +31 -0
  17. package/www/docs/examples/data/globe.msx +0 -0
  18. package/www/docs/examples/data/globe.svg +616 -0
  19. package/www/docs/examples/data/globe.txt +21 -0
  20. package/www/docs/examples/data/globe.zip +0 -0
  21. package/www/docs/examples/data/ne_50m_admin_0_countries.geojson +1 -0
  22. package/www/docs/examples/data/ne_50m_admin_1_states_provinces_lakes.geojson +1 -0
  23. package/www/docs/examples/data/us-states.msx +0 -0
  24. package/www/docs/examples/data/us-states.svg +56 -0
  25. package/www/docs/examples/data/us-states.txt +6 -0
  26. package/www/docs/examples/data/us-states.zip +0 -0
  27. package/www/docs/examples/globe.html +108 -0
  28. package/www/docs/examples/globe.html.md +64 -0
  29. package/www/docs/examples/us-states.html +88 -0
  30. package/www/docs/examples/us-states.html.md +44 -0
  31. package/www/docs/formats/csv.html +127 -0
  32. package/www/docs/formats/csv.html.md +97 -0
  33. package/www/docs/formats/dbf.html +87 -0
  34. package/www/docs/formats/dbf.html.md +39 -0
  35. package/www/docs/formats/flatgeobuf.html +86 -0
  36. package/www/docs/formats/flatgeobuf.html.md +42 -0
  37. package/www/docs/formats/geojson.html +107 -0
  38. package/www/docs/formats/geojson.html.md +65 -0
  39. package/www/docs/formats/geopackage.html +87 -0
  40. package/www/docs/formats/geopackage.html.md +42 -0
  41. package/www/docs/formats/json.html +83 -0
  42. package/www/docs/formats/json.html.md +35 -0
  43. package/www/docs/formats/kml.html +82 -0
  44. package/www/docs/formats/kml.html.md +39 -0
  45. package/www/docs/formats/overview.html +192 -0
  46. package/www/docs/formats/overview.html.md +35 -0
  47. package/www/docs/formats/shapefile.html +123 -0
  48. package/www/docs/formats/shapefile.html.md +84 -0
  49. package/www/docs/formats/snapshot.html +87 -0
  50. package/www/docs/formats/snapshot.html.md +39 -0
  51. package/www/docs/formats/svg.html +99 -0
  52. package/www/docs/formats/svg.html.md +51 -0
  53. package/www/docs/formats/topojson.html +102 -0
  54. package/www/docs/formats/topojson.html.md +54 -0
  55. package/www/docs/gallery/index.html +80 -0
  56. package/www/docs/gallery/index.html.md +29 -0
  57. package/www/docs/guides/combining-layers.html +105 -0
  58. package/www/docs/guides/combining-layers.html.md +81 -0
  59. package/www/docs/guides/expressions.html +600 -0
  60. package/www/docs/guides/expressions.html.md +376 -0
  61. package/www/docs/guides/programmatic.html +117 -0
  62. package/www/docs/guides/programmatic.html.md +91 -0
  63. package/www/docs/guides/projections.html +158 -0
  64. package/www/docs/guides/projections.html.md +118 -0
  65. package/www/docs/guides/simplification.html +110 -0
  66. package/www/docs/guides/simplification.html.md +94 -0
  67. package/www/docs/guides/topology.html +90 -0
  68. package/www/docs/guides/topology.html.md +63 -0
  69. package/www/docs/images/simplification-detail.png +0 -0
  70. package/www/docs/images/simplification-dp.png +0 -0
  71. package/www/docs/images/simplification-mod2.png +0 -0
  72. package/www/docs/index.html +101 -0
  73. package/www/docs/index.html.md +59 -0
  74. package/www/docs/reference.html +1302 -0
  75. package/www/docs/reference.html.md +1817 -0
  76. package/www/docs/whats-new.html +76 -0
  77. package/www/docs/whats-new.html.md +53 -0
  78. package/www/index.html +30 -3
  79. package/www/llms-full.txt +4040 -0
  80. package/www/llms.txt +55 -0
  81. package/www/mapshaper-gui.js +7 -1
  82. package/www/mapshaper.js +1342 -275
  83. package/www/page.css +1 -1
  84. package/www/privacy.html +1 -112
  85. package/www/sponsor.html +4 -164
  86. package/www/terms.html +1 -112
@@ -0,0 +1,88 @@
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 &middot; 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&#39;s new</a></li><li><a href="/docs/reference.html">Command reference</a></li><li><a href="/docs/gallery/">Gallery</a></li></ul><h2>Getting started</h2><ul><li><a href="/docs/essentials/command-line.html">The command-line tool</a></li><li><a href="/docs/essentials/web-app.html">The web app</a></li></ul><h2>Guides</h2><ul><li><a href="/docs/guides/simplification.html">Simplification</a></li><li><a href="/docs/guides/expressions.html">JavaScript expressions</a></li><li><a href="/docs/guides/projections.html">Projections</a></li><li><a href="/docs/guides/topology.html">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> &rsaquo; Examples &rsaquo; 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 &quot;Albers USA&quot; 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">&#x27;admin == &quot;United States of America&quot;&#x27;</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> &mdash; 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> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
84
+ </div>
85
+ </footer>
86
+
87
+ </body>
88
+ </html>
@@ -0,0 +1,44 @@
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
+ ![U.S. States](/docs/examples/data/us-states.svg)
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> &mdash; 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)
@@ -0,0 +1,127 @@
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 &middot; 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&#39;s new</a></li><li><a href="/docs/reference.html">Command reference</a></li><li><a href="/docs/gallery/">Gallery</a></li></ul><h2>Getting started</h2><ul><li><a href="/docs/essentials/command-line.html">The command-line tool</a></li><li><a href="/docs/essentials/web-app.html">The web app</a></li></ul><h2>Guides</h2><ul><li><a href="/docs/guides/simplification.html">Simplification</a></li><li><a href="/docs/guides/expressions.html">JavaScript expressions</a></li><li><a href="/docs/guides/projections.html">Projections</a></li><li><a href="/docs/guides/topology.html">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> &rsaquo; Formats &rsaquo; 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> &middot; <strong>Read:</strong> &check; &middot; <strong>Write:</strong> &check; &middot; <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">&quot;;&quot;</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> &mdash; text encoding. Default is UTF-8.</li>
48
+ <li><code>string-fields=</code> &mdash; 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> &mdash; 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> &mdash; 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> &mdash; import only the first N data rows.</li>
52
+ <li><code>csv-field-names=</code> &mdash; assign explicit field names. Combine with <code>csv-skip-lines=1</code> to override existing headers.</li>
53
+ <li><code>csv-fields=</code> &mdash; 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> &mdash; 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> &mdash; rename duplicate column headers (otherwise Mapshaper errors out).</li>
56
+ <li><code>decimal-comma</code> &mdash; 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> &mdash; text encoding for the output. Default is UTF-8.</li>
61
+ <li><code>delimiter=</code> &mdash; override the field delimiter, e.g. <code>delimiter=&quot;|&quot;</code>.</li>
62
+ <li><code>decimal-comma</code> &mdash; emit numbers using the European decimal-comma convention.</li>
63
+ <li><code>field-order=ascending</code> &mdash; 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> &rarr; comma, <code>.tsv</code> &rarr; 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&hellip;)</h3>
73
+ <p>This is the single biggest CSV footgun. Mapshaper guesses each column&#39;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 &mdash; 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&#39;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&#39;t match <code>2134</code> (number).</p>
82
+ <h3 id="prefiltering-large-csvs">Prefiltering large CSVs</h3>
83
+ <p>For multi-gigabyte CSVs &mdash; election precinct records, OSM extract attribute tables, parcel data &mdash; it usually isn&#39;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> &mdash; keep only the named columns. Wide CSVs (hundreds of columns, only a few of interest) shrink dramatically.</li>
86
+ <li><code>csv-filter=</code> &mdash; 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">&#x27;state == &quot;TX&quot; &amp;&amp; population &gt; &quot;10000&quot;&#x27;</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> &mdash; 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> &mdash; 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&amp;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> &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>
@@ -0,0 +1,97 @@
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` &middot; **Read:** &check; &middot; **Write:** &check; &middot; **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=` &mdash; text encoding. Default is UTF-8.
25
+ - `string-fields=` &mdash; 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=` &mdash; per-field type hints, e.g. `FIPS:str,population:num`. More flexible alternative to `string-fields=`.
27
+ - `csv-skip-lines=` &mdash; skip N lines at the top of the file. Useful for spreadsheet exports with notes above the data.
28
+ - `csv-lines=` &mdash; import only the first N data rows.
29
+ - `csv-field-names=` &mdash; assign explicit field names. Combine with `csv-skip-lines=1` to override existing headers.
30
+ - `csv-fields=` &mdash; import only the named columns. Filtering happens during the read, so this option dramatically reduces peak memory for wide CSVs.
31
+ - `csv-filter=` &mdash; a JavaScript expression evaluated per row. Rows that return false are dropped before they ever reach the layer.
32
+ - `csv-dedup-fields` &mdash; rename duplicate column headers (otherwise Mapshaper errors out).
33
+ - `decimal-comma` &mdash; parse numbers using `1.000,01` European convention instead of `1,000.01`.
34
+
35
+ ### Format-specific output options
36
+
37
+ - `encoding=` &mdash; text encoding for the output. Default is UTF-8.
38
+ - `delimiter=` &mdash; override the field delimiter, e.g. `delimiter="|"`.
39
+ - `decimal-comma` &mdash; emit numbers using the European decimal-comma convention.
40
+ - `field-order=ascending` &mdash; sort columns alphabetically.
41
+
42
+ ### Practical notes
43
+
44
+ - The delimiter is auto-detected from the extension (`.csv` &rarr; comma, `.tsv` &rarr; 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&hellip;)
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 &mdash; 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 &mdash; election precinct records, OSM extract attribute tables, parcel data &mdash; 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=` &mdash; keep only the named columns. Wide CSVs (hundreds of columns, only a few of interest) shrink dramatically.
73
+ - `csv-filter=` &mdash; 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) &mdash; 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/) &mdash; a practical schema for declaring how a particular CSV file is formatted (delimiter, quoting, line terminator).
@@ -0,0 +1,87 @@
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 &middot; 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&#39;s new</a></li><li><a href="/docs/reference.html">Command reference</a></li><li><a href="/docs/gallery/">Gallery</a></li></ul><h2>Getting started</h2><ul><li><a href="/docs/essentials/command-line.html">The command-line tool</a></li><li><a href="/docs/essentials/web-app.html">The web app</a></li></ul><h2>Guides</h2><ul><li><a href="/docs/guides/simplification.html">Simplification</a></li><li><a href="/docs/guides/expressions.html">JavaScript expressions</a></li><li><a href="/docs/guides/projections.html">Projections</a></li><li><a href="/docs/guides/topology.html">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> &rsaquo; Formats &rsaquo; DBF</div>
35
+ <h1 id="dbf">DBF</h1>
36
+ <p>DBF is the dBase database format. It&#39;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> &middot; <strong>Read:</strong> &check; &middot; <strong>Write:</strong> &check; &middot; <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">&#x27;&quot;BC,AB,SK&quot;.indexOf(prov) &gt; -1&#x27;</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> &mdash; 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> &mdash; output text encoding. Default UTF-8 (with a matching <code>.cpg</code> sidecar).</li>
50
+ <li><code>field-order=ascending</code> &mdash; sort columns alphabetically.</li>
51
+ </ul>
52
+ <h3 id="practical-notes">Practical notes</h3>
53
+ <ul>
54
+ <li>DBF holds tabular data only &mdash; 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> &mdash; useful overview of the format&#39;s history and dialects.</li>
62
+ <li><a href="https://www.clicketyclick.dk/databases/xbase/format/">Xbase File Format Description</a> &mdash; Erik Bachmann&#39;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> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
83
+ </div>
84
+ </footer>
85
+
86
+ </body>
87
+ </html>
@@ -0,0 +1,39 @@
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` &middot; **Read:** &check; &middot; **Write:** &check; &middot; **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=` &mdash; 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=` &mdash; output text encoding. Default UTF-8 (with a matching `.cpg` sidecar).
27
+ - `field-order=ascending` &mdash; sort columns alphabetically.
28
+
29
+ ### Practical notes
30
+
31
+ - DBF holds tabular data only &mdash; 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) &mdash; useful overview of the format's history and dialects.
39
+ - [Xbase File Format Description](https://www.clicketyclick.dk/databases/xbase/format/) &mdash; Erik Bachmann's reference for the dBase / xBase family. The standard external citation for byte-level DBF details.
@@ -0,0 +1,86 @@
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 &middot; 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&#39;s new</a></li><li><a href="/docs/reference.html">Command reference</a></li><li><a href="/docs/gallery/">Gallery</a></li></ul><h2>Getting started</h2><ul><li><a href="/docs/essentials/command-line.html">The command-line tool</a></li><li><a href="/docs/essentials/web-app.html">The web app</a></li></ul><h2>Guides</h2><ul><li><a href="/docs/guides/simplification.html">Simplification</a></li><li><a href="/docs/guides/expressions.html">JavaScript expressions</a></li><li><a href="/docs/guides/projections.html">Projections</a></li><li><a href="/docs/guides/topology.html">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> &rsaquo; Formats &rsaquo; 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> &middot; <strong>Read:</strong> &check; &middot; <strong>Write:</strong> &check; &middot; <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>FlatGeobuf is single-layer per file. Use <a href="/docs/formats/geopackage.html">GeoPackage</a> or <a href="/docs/formats/topojson.html">TopoJSON</a> when you need to package multiple layers in one file.</li>
50
+ <li>Mapshaper reads CRS metadata from the file header when it&#39;s encoded as an EPSG code. WKT2-only definitions can&#39;t be parsed and produce an &quot;Unable to import WKT2 CRS from FlatGeobuf&quot; warning &mdash; the layer comes in without a CRS.</li>
51
+ <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[&quot;EPSG&quot;, 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>
52
+ <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>&quot;Wrote <code>foo.fgb</code> without a CRS in the FlatGeobuf header...&quot;</em>. Re-run the file through <code>ogr2ogr</code> if you need the CRS embedded for downstream tools.</li>
53
+ <li>Mapshaper does not write the optional packed R-tree spatial index, and it doesn&#39;t use the index for selective reads of indexed input either &mdash; 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>
54
+ </ul>
55
+ <h2 id="external-resources">External resources</h2>
56
+ <ul>
57
+ <li><a href="https://flatgeobuf.org/">flatgeobuf.org</a> &mdash; project home with spec links and language bindings.</li>
58
+ <li><a href="https://worace.works/2022/02/23/kicking-the-tires-flatgeobuf/">Kicking the Tires: FlatGeobuf</a> &mdash; an independent practical writeup with benchmarks against Shapefile, GeoJSON and GeoPackage.</li>
59
+ <li><a href="https://brycemecum.com/2022/04/04/flatgeobuf/">Bryce Mecum: Flatgeobuf</a> &mdash; 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>
60
+ <li><a href="https://guide.cloudnativegeo.org/flatgeobuf/">Cloud-Native Geospatial Formats Guide: FlatGeobuf</a> &mdash; how the format fits into modern cloud-storage workflows.</li>
61
+ <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>
62
+ </ul>
63
+
64
+ <div class="edit-link">
65
+ <a href="https://github.com/mbloch/mapshaper/edit/master/docs/formats/flatgeobuf.md">Edit this page on GitHub</a>
66
+ </div>
67
+ </article>
68
+ </main>
69
+
70
+ <aside class="docs-toc">
71
+ <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>
72
+ </aside>
73
+
74
+ </div>
75
+
76
+ <script src="/docs/_assets/docs.js" defer></script>
77
+
78
+ <footer class="docs-footer">
79
+ <div class="docs-footer-inner">
80
+ <span>mapshaper is free software, licensed under <a href="https://www.mozilla.org/MPL/2.0/">MPL 2.0</a>.</span>
81
+ <span><a href="/privacy.html">Privacy</a> &middot; <a href="/terms.html">Terms</a> &middot; <a href="/sponsor.html">Support mapshaper</a></span>
82
+ </div>
83
+ </footer>
84
+
85
+ </body>
86
+ </html>