The total process takes about 1 hour.
Download "WGS 84, Large polygons not split" from osmdata, unpack and store the shapefile in
00-static-data/land-polygons-complete-4326
Direct link: https://osmdata.openstreetmap.de/download/land-polygons-complete-4326.zip
Landing page: https://osmdata.openstreetmap.de/data/land-polygons.html
You may want to open the file in mapshaper and check that the polygons do not self-intersect, because clipping with self-intersecting polygons will corrupt data. For example, clipping with these polygons removes most of Japan from the output:
You can also use this snapshot of land polygons with correct polygons.
Natural earth data (1:10m Cultural Vectors) is used for zoom levels 0 to 4 for compatibility with OpenMapTiles.
Download "countries" and "states and provinces" and unpack and store the shapefiles in
00-static-data/ne_10m_admin_0_countries
00-static-data/ne_10m_admin_1_states_provinces
Direct links:
- https://naciscdn.org/naturalearth/10m/cultural/ne_10m_admin_0_countries.zip
- https://naciscdn.org/naturalearth/10m/cultural/ne_10m_admin_1_states_provinces.zip
Landing page: https://www.naturalearthdata.com/downloads/10m-cultural-vectors/
Run
npm install
to install the dependencies.
Run this script to execute all steps listed below:
import-osm/import-osm.sh
Input: Nothing. Output: List of countries with ISO3166-1 codes.
Input: List of countries with ISO3166-1 codes. Output: For every country, one GeoJSON file with country and subdivision polygons.
Also store raw data only download if raw data is not available.
Input: For every country, one GeoJSON file with country and subdivision polygons. Output: For every country, one GeoJSON file with country and subdivision polygons.
Input: For every country, one GeoJSON file with country and subdivision polygons. Output: For every country, one GeoJSON file with country and subdivision polygons.
Input: For every country, one GeoJSON file with country and subdivision polygons. Output: For every region, one GeoJSON file.
Input: For every region, one GeoJSON file. Output: For every region, one GeoJSON file.
Input: For every country, one GeoJSON file with country and subdivision polygons. Output: One GeoJSON file with all countries, one GeoJSON file with all subdivisions.
Input: One GeoJSON file with all countries, one GeoJSON file with all subdivisions. Output: mbtiles file with 2 layers (countries, subdivisions).
Input: Shapefiles with countries and states/provinces. Output: GeoJSON files with countries and states/provinces.
Input: GeoJSON files with countries and states/provinces. Output: mbtiles file with 2 layers (countries, subdivisions).
Input: mbtiles files from steps 8/10. Output: mbtiles file with 2 layers (countries, subdivisions), using natural earth data for zoom levels 0-4 and Openstreetmap data for zoom levels 5-10.
Run this to remove all output
folders:
import-osm/remove-outputs.sh
Run this script to preview the vector tiles generated in step 11.
import-osm/preview-tiles.sh