mapshaper 0.7.0 → 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.
- package/README.md +5 -3
- package/mapshaper.js +363 -62
- package/package.json +5 -2
- package/www/assets/jetbrains-mono-regular.woff2 +0 -0
- package/www/assets/static-page.css +179 -0
- package/www/docs/_assets/cmd-search.js +213 -0
- package/www/docs/_assets/docs.css +712 -0
- package/www/docs/_assets/docs.js +75 -0
- package/www/docs/_assets/highlight.css +10 -0
- package/www/docs/essentials/command-line.html +127 -0
- package/www/docs/essentials/command-line.html.md +112 -0
- package/www/docs/essentials/web-app.html +138 -0
- package/www/docs/essentials/web-app.html.md +106 -0
- package/www/docs/examples/basics.html +276 -0
- package/www/docs/examples/basics.html.md +371 -0
- package/www/docs/examples/data/Makefile +31 -0
- package/www/docs/examples/data/globe.msx +0 -0
- package/www/docs/examples/data/globe.svg +616 -0
- package/www/docs/examples/data/globe.txt +21 -0
- package/www/docs/examples/data/globe.zip +0 -0
- package/www/docs/examples/data/ne_50m_admin_0_countries.geojson +1 -0
- package/www/docs/examples/data/ne_50m_admin_1_states_provinces_lakes.geojson +1 -0
- package/www/docs/examples/data/us-states.msx +0 -0
- package/www/docs/examples/data/us-states.svg +56 -0
- package/www/docs/examples/data/us-states.txt +6 -0
- package/www/docs/examples/data/us-states.zip +0 -0
- package/www/docs/examples/globe.html +108 -0
- package/www/docs/examples/globe.html.md +64 -0
- package/www/docs/examples/us-states.html +88 -0
- package/www/docs/examples/us-states.html.md +44 -0
- package/www/docs/formats/csv.html +127 -0
- package/www/docs/formats/csv.html.md +97 -0
- package/www/docs/formats/dbf.html +87 -0
- package/www/docs/formats/dbf.html.md +39 -0
- package/www/docs/formats/flatgeobuf.html +86 -0
- package/www/docs/formats/flatgeobuf.html.md +42 -0
- package/www/docs/formats/geojson.html +107 -0
- package/www/docs/formats/geojson.html.md +65 -0
- package/www/docs/formats/geopackage.html +87 -0
- package/www/docs/formats/geopackage.html.md +42 -0
- package/www/docs/formats/json.html +83 -0
- package/www/docs/formats/json.html.md +35 -0
- package/www/docs/formats/kml.html +82 -0
- package/www/docs/formats/kml.html.md +39 -0
- package/www/docs/formats/overview.html +192 -0
- package/www/docs/formats/overview.html.md +35 -0
- package/www/docs/formats/shapefile.html +123 -0
- package/www/docs/formats/shapefile.html.md +84 -0
- package/www/docs/formats/snapshot.html +87 -0
- package/www/docs/formats/snapshot.html.md +39 -0
- package/www/docs/formats/svg.html +99 -0
- package/www/docs/formats/svg.html.md +51 -0
- package/www/docs/formats/topojson.html +102 -0
- package/www/docs/formats/topojson.html.md +54 -0
- package/www/docs/gallery/index.html +80 -0
- package/www/docs/gallery/index.html.md +29 -0
- package/www/docs/guides/combining-layers.html +105 -0
- package/www/docs/guides/combining-layers.html.md +81 -0
- package/www/docs/guides/expressions.html +600 -0
- package/www/docs/guides/expressions.html.md +376 -0
- package/www/docs/guides/programmatic.html +117 -0
- package/www/docs/guides/programmatic.html.md +91 -0
- package/www/docs/guides/projections.html +158 -0
- package/www/docs/guides/projections.html.md +118 -0
- package/www/docs/guides/simplification.html +110 -0
- package/www/docs/guides/simplification.html.md +94 -0
- package/www/docs/guides/topology.html +90 -0
- package/www/docs/guides/topology.html.md +63 -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/index.html +101 -0
- package/www/docs/index.html.md +59 -0
- package/www/docs/reference.html +1302 -0
- package/www/docs/reference.html.md +1817 -0
- package/www/docs/whats-new.html +76 -0
- package/www/docs/whats-new.html.md +53 -0
- package/www/index.html +30 -3
- package/www/llms-full.txt +4040 -0
- package/www/llms.txt +55 -0
- package/www/mapshaper-gui.js +7 -1
- package/www/mapshaper.js +363 -62
- package/www/page.css +1 -1
- package/www/privacy.html +1 -112
- package/www/sponsor.html +4 -164
- package/www/terms.html +1 -112
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Tutorial: combining two layers"
|
|
3
|
+
description: A step-by-step walkthrough of combining and pruning two boundary layers to produce a custom GeoJSON basemap.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tutorial: combining two layers in the web UI
|
|
7
|
+
|
|
8
|
+
> Originally contributed by Amanda Hickman to the project wiki.
|
|
9
|
+
|
|
10
|
+
This walkthrough shows how to combine and prune two boundary layers to produce a single GeoJSON file you can use as a custom basemap (for example, in [Datawrapper](https://www.datawrapper.de/)).
|
|
11
|
+
|
|
12
|
+
The example builds a basemap of the San Francisco Bay Area, with both county boundaries and the cities ("places") inside them.
|
|
13
|
+
|
|
14
|
+
The walkthrough uses the web app at [mapshaper.org](/), driving the workflow from the **Console**. The same commands work on the CLI — chain them together with leading `-` prefixes (so `clip bayarea_county` becomes `-clip bayarea_county`) and connect them with backslash line continuations.
|
|
15
|
+
|
|
16
|
+
## The starting data
|
|
17
|
+
|
|
18
|
+
We'll use two source files:
|
|
19
|
+
|
|
20
|
+
- A county boundary file from the California Open Data Portal — or, in this case, a [version clipped to the shoreline](https://geodata.lib.berkeley.edu/catalog/ark28722-s7hs4j) from UC Berkeley's Geo Data Commons. The shoreline-clipped version reads more naturally on a map than the legal-boundary version, which extends into the bay.
|
|
21
|
+
- A statewide [places boundary file](https://geodata.lib.berkeley.edu/catalog/ark28722-s7bp4z) for city boundaries.
|
|
22
|
+
|
|
23
|
+
Download both as `.zip` files.
|
|
24
|
+
|
|
25
|
+
## Open them in Mapshaper
|
|
26
|
+
|
|
27
|
+
Drag the two `.zip` files onto [mapshaper.org](/), or run the web app locally with `mapshaper-gui`. You'll end up with two layers loaded into the session.
|
|
28
|
+
|
|
29
|
+
## Set the projection
|
|
30
|
+
|
|
31
|
+
Datawrapper expects WGS84 coordinates. Open the **Console** (top-right of the header) and run, with each layer selected:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
proj wgs84
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You'll need to run this once per layer — switch which layer is selected in the layer panel between runs.
|
|
38
|
+
|
|
39
|
+
→ See the [`-proj` reference](/docs/reference.html.md#-proj).
|
|
40
|
+
|
|
41
|
+
## Clip the places layer to the Bay Area
|
|
42
|
+
|
|
43
|
+
The places layer covers the whole state. We only want places inside the Bay Area counties. With the places layer selected:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
clip bayarea_county
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
→ See the [`-clip` reference](/docs/reference.html.md#-clip).
|
|
50
|
+
|
|
51
|
+
Alternatively, if the places layer has a `COUNTY` attribute, a filter expression works too:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
filter '["Marin", "Contra Costa", "Alameda",
|
|
55
|
+
"San Francisco", "Santa Clara", "San Mateo"].includes(COUNTY)'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
→ See the [`-filter` reference](/docs/reference.html.md#-filter).
|
|
59
|
+
|
|
60
|
+
## Merge the layers
|
|
61
|
+
|
|
62
|
+
The two layers can now be combined into a single layer with [`-merge-layers`](/docs/reference.html.md#-merge-layers):
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
merge-layers target=bayarea_county,california_place_clipped force
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The `force` flag is needed because the two layers have different attribute schemas; without it, Mapshaper refuses to merge layers whose fields don't match.
|
|
69
|
+
|
|
70
|
+
## Export
|
|
71
|
+
|
|
72
|
+
Open the **Export** panel (top-right of the header), pick **GeoJSON** as the format, and save the merged layer. You can now upload that file to Datawrapper (or any other tool that accepts GeoJSON) as a custom basemap.
|
|
73
|
+
|
|
74
|
+
## What you've learned
|
|
75
|
+
|
|
76
|
+
- How to load multiple data files into one Mapshaper session.
|
|
77
|
+
- How to apply a projection inside the web UI's console.
|
|
78
|
+
- How to clip one layer by another.
|
|
79
|
+
- How to merge two layers into a single layer for export.
|
|
80
|
+
|
|
81
|
+
For more on layers and how Mapshaper organizes multi-layer datasets, see [The command-line tool](/docs/essentials/command-line.html.md#working-with-layers).
|