one-off vector tiles
Let’s set up some bespoke data layers!
Motivation
We might do this to build a visualization to debug some data in OSM, for which a general-purpose vector map tiler would not meet our needs.
For example, here’s a statewide map including all administrative and census boundaries in Pennsylvania.
On a typical map we wouldn’t see the admin boundaries until zoom 11, 12, perhaps 14. The census boundaries probably wouldn’t be rendered at all. So we need to extract the data we’re interested, perhaps rendering it atop a general-purpose basemap.
Shown here at approximately zoom level 8.
Reasons this could be useful:
- Specialized views of any vector data, OSM or other
-
This could similarly useful for any feature set that you need a dense, small scale map of.
And some numbers for the curious:
- Raw json OSM data from overpass - 38M (5M gzipped)
- Geojson output - 42M (5M gzipped)
- Mbtiles - 110M (87M gzipped)
- Unpacked tiles - 199M (47,561 files)
We can open the geojson directly in e.g. Kepler, but it’s still a large download, and very slow. Simplifying for low zoom levels is important.
(The mbtiles contains zoom levels 0 thru 14)
Let’s get started! Our data pipeline will look roughly like this:
1. Extract with overpass
2. Convert to mbtiles
3. Develop a stylesheet
4. Host it somewhere
1. Extract with overpass
[out:json];
area[wikidata=Q1400]->.a; // Pennsylvania
( rel(area.a)[type=boundary][boundary=administrative];
rel(area.a)[type=boundary][boundary=census]; );
out;>;out skel qt;
We’ll repeat this for each state we need.
> Idea: We need to keep the layers separate so that we can style them differently, but perhaps we could add a property to each feature indicating what state it’s from.
curl 'https://overpass-api.de/api/interpreter' --get --data-urlencode 'data=(insert query)' > pa.json
2. Convert to mbtiles
Tippecanoe can only consume geojson, so first convert the OSM data:
npm install osmtogeojson