|
| 1 | +# Building a custom basemap |
| 2 | + |
| 3 | +The Protomaps Basemap based on OpenStreetMap data is provided as a [free daily planet build](/basemaps/downloads), which can be downloaded in full, or extracted into sub-pyramids for certain areas. |
| 4 | + |
| 5 | +The pipeline to generate this daily basemap [is open source](https://github.com/protomaps/basemaps/tree/main/tiles) and based on the [Planetiler](https://github.com/onthegomap/planetiler) Java tiling engine. It can be run for your local city or country in minutes, or in about two hours for the planet on a high-end desktop or server. |
| 6 | + |
| 7 | +Advantages to generating basemaps yourself include: |
| 8 | + |
| 9 | +* **Data** - Build tiles from specific OpenStreetMap snapshots, such as up-to-the-minute data from [SliceOSM](https://slice.openstreetmap.us). |
| 10 | +* **Customization** - modify the Java code to include custom tags. |
| 11 | +* **Clipping** - build a custom, focused area map. Extracting an area from the daily planet build will include extra data in low zoom tiles, like in the below illustration: |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +## Build a local map |
| 16 | + |
| 17 | +To start you will need: |
| 18 | + |
| 19 | +* a [Java Runtime Environment version 21+](https://github.com/onthegomap/planetiler/blob/main/CONTRIBUTING.md) and [Maven](https://maven.apache.org/install.html) installed. |
| 20 | + |
| 21 | +* An OpenStreetMap extract that covers your area of interest, such as an on-demand download from [SliceOSM](https://slice.openstreetmap.us) or a pre-generated download from [Geofabrik Downloads](https://download.geofabrik.de). |
| 22 | + |
| 23 | +* A GeoJSON administrative boundary for Łódź, Poland downloaded from the [Who's On First Spelunker](https://spelunker.whosonfirst.org/id/101913783). [Link to lodz.geojson](https://spelunker.whosonfirst.org/id/101913783/geojson) |
| 24 | + |
| 25 | +### Generate the map |
| 26 | + |
| 27 | +1. Create a checkout of the `basemaps` project and build the JAR. |
| 28 | + |
| 29 | +```sh |
| 30 | +git clone https://github.com/protomaps/basemaps |
| 31 | +cd tiles |
| 32 | +mvn clean package |
| 33 | +``` |
| 34 | + |
| 35 | +2. Place your input OSM data into `data/sources` and run the tile generation JAR: |
| 36 | + |
| 37 | +```sh |
| 38 | +cp my_area.osm.pbf data/sources/my_area.osm.pbf |
| 39 | +java -jar target/protomaps-basemap-HEAD-with-deps.jar --clip=lodz.geojson --area=my_area --download |
| 40 | +``` |
| 41 | + |
| 42 | +This will also download resources such as pre-processed OSM water and land polygons, [Natural Earth](https://naturalearthdata.com), and datasets for language support and ranking. |
| 43 | + |
| 44 | +3. Drag-and-drop your output `.pmtiles` to the [Basemaps Viewer at maps.protomaps.com](https://maps.protomaps.com): |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +## Build the planet |
| 49 | + |
| 50 | +The recommended system requirements for building a planet tileset are: |
| 51 | + |
| 52 | +* CPU: As many CPU cores as possible. Recommended: Intel Core i9 series, AMD Ryzen 9 series, AWS `c7gd.8xlarge` or equivalent. |
| 53 | +* RAM: 64GB of RAM. |
| 54 | +* Storage: At least 1TB of NVMe SSD storage, or attached instance store on a VPS (not network-attached storage) |
| 55 | + |
| 56 | +Building the planet works the same way as before, but provide a Planet file from [planet.openstreetmap.org](http://planet.openstreetmap.org) as the `--area` argument, or `--osm_file` with a complete path and `--bounds=planet`. |
| 57 | + |
| 58 | +```sh |
| 59 | +java -Xmx20g -jar target/protomaps-basemap-HEAD-with-deps.jar --nodemap-type=array --osm_path=/data/planet-latest.osm.pbf --output=/data/planet.pmtiles --bounds=planet --tmpdir=/var/scratch |
| 60 | +``` |
| 61 | + |
| 62 | +* `-Xmx20g`: Give the Java runtime environment 20GB of heap space. |
| 63 | +* `--nodemap-type=array`: a build option best for planet tile generation. |
| 64 | +* `--tmpdir=/var/scratch`: ensure there is at least 512GB of scratch space. |
0 commit comments