This OpenMapTiles profile for Planetiler is based on OpenMapTiles.
Using pre-built docker image:
docker run -v "$(pwd)/data":/data openmaptiles/planetiler-openmaptiles:latest --force --download --area=monaco
Or to build from source, after installing Java 21+:
# Build the project (use mvnw.cmd on windows):
./mvnw clean package
# Then run:
java -jar target/*with-deps.jar --force --download --area=monaco
See Planetiler README.md for more description of the available options.
- Clone repo and cd into root folder
- Build from source (see instructions above)
- Run (maybe do a test run with
--area=switzerland
) Light build:
java -Xmx20g \
-jar target/*with-deps.jar --force \
`# Download the latest planet.osm.pbf from s3://osm-pds bucket` \
--area=planet --bounds=planet --download \
`# Accelerate the download by fetching the 10 1GB chunks at a time in parallel` \
--download-threads=10 --download-chunk-size-mb=1000 \
`# Also download name translations from wikidata` \
--fetch-wikidata \
--output=data/output.mbtiles \
`# Store temporary node locations at fixed positions in a memory-mapped file` \
--nodemap-type=array --storage=mmap \
`# Configure layers and languages` \
--languages= \
--only-layers=boundary,water,place,waterway,mountain_peak,water_name \
--boundary_simplify=true \
--boundary_osm_only=true \
--place_simplify=true \
--simplify_tolerance=0.2
Full build:
java -Xmx20g \
-jar target/*with-deps.jar --force \
`# Download the latest planet.osm.pbf from s3://osm-pds bucket` \
--area=planet --bounds=planet --download \
`# Accelerate the download by fetching the 10 1GB chunks at a time in parallel` \
--download-threads=10 --download-chunk-size-mb=1000 \
`# Also download name translations from wikidata` \
--fetch-wikidata \
--output=data/output.mbtiles \
`# Store temporary node locations at fixed positions in a memory-mapped file` \
--nodemap-type=array --storage=mmap \
`# Configure layers and languages` \
--languages=en,de,fr,nl,dk,cs,it,pl,es,pt,uk,fi,no,sv,ja,zh \
--only-layers=boundary,water,place,waterway,mountain_peak,water_name,landuse,landcover,park,transportation,transportation_name,aeroway \
--boundary_simplify=true \
--boundary_osm_only=true \
--place_simplify=false \
--simplify_tolerance=0.2
- View tiles:
npm install -g tileserver-gl-light && tileserver-gl-light --file data/output.mbtiles
and visit http://localhost:8080 --> you should be able to click
For testing use:
java -jar target/*with-deps.jar --force --area=italy --download --only-layers=boundary,water,place,waterway,mountain_peak,water_name --languages= --boundary_simplify=true --boundary_osm_only=true --place_simplify=true --simplify_tolerance=0.2
For full testing use:
java -jar target/*with-deps.jar --force --area=italy --download --only-layers=boundary,water,place,waterway,mountain_peak,water_name,landuse,landcover,park,transportation,transportation_name,aeroway --languages=en,de,fr,nl,dk,cs,it,pl,es,pt,uk,fi,no,sv,ja,zh --boundary_simplify=true --boundary_osm_only=true --place_simplify=false --simplify_tolerance=0.2
- Road name abbreviations are not implemented yet in the
transportation_name
layer brunnel
tag is excluded fromtransportation_name
layer to avoid breaking apart longtransportation_name
lines, to revert this behavior set--transportation-name-brunnel=true
rank
field onmountain_peak
linestrings only has 3 levels (1: has wikipedia page and name, 2: has name, 3: no name or wikipedia page or name)- some line and polygon tolerances are different, can be tweaked with
--simplify-tolerance
parameter
If you want to exclude layers or only include certain layers, then run the project
with --exclude-layers=poi,housenumber,...
or --only-layers=water,transportation,...
command-line arguments.
If you want to customize existing layers in OpenMapTiles, then fork this repo, find the appropriate class from the layers package, and make a change to where it processes output features.
Example adding an attribute to a built-in layer
For example to copy over the name attribute from OpenStreetMap elements to the building layer, modify Building.java:
@@ -166,6 +166,7 @@ public class Building implements
.setAttrWithMinzoom(Fields.RENDER_MIN_HEIGHT, renderMinHeight, 14)
.setAttrWithMinzoom(Fields.COLOUR, color, 14)
.setAttrWithMinzoom(Fields.HIDE_3D, hide3d, 14)
+ .setAttrWithMinzoom("name", element.source().getTag("name"), 14)
.setSortKey(renderHeight);
if (mergeZ13Buildings) {
feature
If you want to generate a mbtiles file with OpenMapTiles base layers plus some extra ones then fork this repo and:
- Create a new class that implements the
Layer
interface in the addons package and make thepublic String name()
method return the ID of the new layer. - Make the new class implement interfaces from
OpenMapTilesProfile
to register handlers for elements from input sources. For example implementOpenMapTilesProfile.OsmAllProcessor
to handle every OSM element fromprocessAllOsm
method. See the built-in layers for examples. - Create a new instance of that class from the
ExtraLayers
class.
Custom layer example
This layer would add a power
layer to OpenMapTiles output with power lines:
package org.openmaptiles.addons;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.reader.SourceFeature;
import org.openmaptiles.Layer;
import org.openmaptiles.OpenMapTilesProfile;
public class Power implements Layer, OpenMapTilesProfile.OsmAllProcessor {
private static final String LAYER_NAME = "power";
@Override
public String name() {
return LAYER_NAME;
}
@Override
public void processAllOsm(SourceFeature feature, FeatureCollector features) {
if (feature.canBeLine() && feature.hasTag("power", "line")) {
features.line("power")
.setBufferPixels(4)
.setMinZoom(6)
.setAttr("class", "line");
}
}
}
If you think your custom layer or change to a built-in layer might be useful to others, consider opening a pull request
to contribute it back to this repo. Any change that diverges from what is produced
by https://github.com/openmaptiles/openmaptiles should be disabled by default, and enabled through a command-line
argument that users can opt-into. For example, see how
the building layer exposes a building_merge_z13
command-line
argument to disable merging nearby buildings at z13.
Generate.java generates code in the generated package from an OpenMapTiles tag in GitHub:
- OpenMapTilesSchema contains an interface for each layer with constants for the name, attributes, and allowed values for each tag in that layer
- Tables contains a record for each table that OpenMapTiles imposm3 configuration generates (along with the tag-filtering expression) so layers can listen on instances of those records instead of doing the tag filtering and parsing themselves
The layers package contains a port of the SQL logic to generate each layer from OpenMapTiles. Layers define how source features (or parsed imposm3 table rows) map to vector tile features, and logic for post-processing tile geometries.
OpenMapTilesProfile dispatches source features to layer handlers and merges the results.
OpenMapTilesMain is the main driver that registers source data and output location.
To run Generate.java
,
use scripts/regenerate-openmaptiles.sh
script with the
OpenMapTiles release tag:
./scripts/regenerate-openmaptiles.sh v3.14
Then follow the instructions it prints for reformatting generated code.
If you want to regenerate from a different repository than the default openmaptiles, you can specify the url like this:
./scripts/regenerate-openmaptiles.sh v3.14 https://raw.githubusercontent.com/openmaptiles/openmaptiles/
All code in this repository is under the BSD license and the cartography decisions encoded in the schema and SQL are licensed under CC-BY.
Products or services using maps derived from OpenMapTiles schema need to visibly credit "OpenMapTiles.org" or reference "OpenMapTiles" with a link to https://openmaptiles.org/. Exceptions to attribution requirement can be granted on request.
For a browsable electronic map based on OpenMapTiles and OpenStreetMap data, the credit should appear in the corner of the map. For example:
© OpenMapTiles © OpenStreetMap contributors
For printed and static maps a similar attribution should be made in a textual description near the image, in the same fashion as if you cite a photograph.