Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to create Custom pmtiles from osm.pbf files (change minZoom, add more elements that are missing in default schema) #1485

Unanswered
ovisopa asked this question in Q&A
Discussion options

Hello everyone,
I'm new to OSM, 2 months ago I started to build an iOS/Android app and very fast I understood I can't use an tile server like mapTiler because of the free tier limits, so I got an 64Gb +1TB NVME workstation to use it as a full PLANET tile server.

I installed the needed software, I run Martin, NGIX + CloudFlare tunnel and I was able to generate the pmtiles from a osm.pbf file I downloaded from geofabrik. To make things easy in the beginning I only downloaded Romania pbf, and build my tiles using this script:

#!/bin/bash
# Move to the project root
cd "$(dirname "0ドル")/.."
# Default to Bucharest for the test, but we can change this later
AREA=${1:-romania}
MEMORY=${2:-48g}
echo "Building map for: $AREA with $MEMORY RAM..."
java -Xmx$MEMORY -jar bin/planetiler.jar \
 --osm-path=data/$AREA-latest.osm.pbf \
 --output=data/$AREA.pmtiles \
 --area=$AREA \
 --force "$@"
echo "Done! Output saved to data/$AREA.pmtiles"

than I started styling my maps, element by element, after a few days I noticed there are some elements that are not available in my pmtiles ( natural: [spring], man_made: [tower, mast, antenna], waterway: [waterfall] )

In the last few evening I tried to generate the tiles with the missing elements and also I needed to change the min-zoom value for some elements like paths, trails and also to some POIs.

I tried multiple ways, here are a few scripts I used but I wasn't able to add the springs in my map :(

java -Xmx$MEMORY -jar bin/planetiler.jar \
 --osm-path=data/$AREA-latest.osm.pbf \
 --output=data/${AREA}_final.pmtiles \
 --nodemap-type=sparsearray \
 --storage=mmap \
 --area=$AREA \
 --force \
 --transportation-z13-paths=true \
 --extra-name-tags=natural,man_made,waterway,amenity,historic \
 --include-tags=true \
 --keep-tags=natural,man_made,waterway,amenity,historic \
 --all-names=true \
 --schema=configs/topo.yml
 # configs/topo.yml
schema:
 - id: topo_pois
 type: point
 osm:
 - tags:
 natural: [spring]
 man_made: [tower, mast, antenna]
 waterway: [waterfall]
 amenity: [drinking_water]
 mapping:
 name: name
 topotype: ["coalesce", ["get", "natural"], ["get", "man_made"], ["get", "amenity"]]
 minzoom: 10
 maxzoom: 14
 # config/planetiler.properties file
 # This forces the POI layer to be more inclusive
poi_class_include=spring,tower,communications_tower,waterfall,drinking_water
poi_min_zoom=10`
`java -Xmx$MEMORY -jar bin/planetiler.jar \
 --osm-path=data/$AREA-latest.osm.pbf \
 --output=data/${AREA}_topo.pmtiles \
 --nodemap-type=sparsearray \
 --storage=mmap \
 --area=$AREA \
 --force \
 --transportation-z13-paths=true \
 --transportation-name-limit-merge=false \
 --building-merge-z13=false

Can anyone guide me to the correct path to be able to generate pmtiles with all the missing elements?

I don't know if the correct way is to generate a set of pmtiles with the default schema, and than to generate the missing tiles in a separate pmtiles file, I think it would be better to have only one CORRECT set of tiles.

Is there a way to create a new COMPLETE schema and to use it as a parameter? (I have tried passing parameters to planetiler.jar with a different yml schema but it didn't do what I expected, the number of elements in the tiles has increased but my springs, communication towers , etc did not appear in the map, and I use MapLibre to style these elements, if the elements ware in my tiles for sure they should have been displayed)

I never build any java code, and not really sure where is the schema that planetiler.jar is using by default, is it this one ? https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/src/main/java/org/openmaptiles/generated/OpenMapTilesSchema.java

Thank you for any advices !

PS. Bellow I post a few screenshots, and also explain why I need to modify the min zoom on some elements

This one is at Z 12.99
image

And the one bellow is at Zoom level 13. I know the rivers/streams seem to thick but that can be easily style out, the problem is I need these and also all the trails visible even in zoom 12, I will style them to be less visible, but I need them in my tiles at z12.

So can these settings be changed when I run planetile.jar ?

image
You must be logged in to vote

Replies: 2 comments

Comment options

Hello! Currently the only way to customize the generated openmaptiles tiles is to fork https://github.com/openmaptiles/planetiler-openmaptiles and make changes there. You can also use yaml schemas to create a separate pmtiles file. I have a Google Summer of Code project proposal out for this summer that would address this issue and let you combine multiple profiles into a single output pmtiles (as well as filter the generated pmtiles file to just what your maplibre style needs) so hopefully this will be possible in the near future.

You must be logged in to vote
0 replies
Comment options

Thank you for your quick reply @msbarry !

... is to fork https://github.com/openmaptiles/planetiler-openmaptiles and make changes there

I opened file /openmaptiles/layers/Transportation.java

minzoom = switch (baseClass) {
 case FieldValues.CLASS_SERVICE -> isDrivewayOrParkingAisle(service(element.service())) ? 14 : 13;
 case FieldValues.CLASS_TRACK, FieldValues.CLASS_PATH -> routeRank == 1 ? 12 :
 (z13Paths || !nullOrEmpty(element.name()) || routeRank <= 2 || !nullOrEmpty(element.sacScale())) ? 13 : 14;
 case FieldValues.CLASS_TRUNK -> {
 boolean z5trunk = isTrunkForZ5(highway, routeRelations);
 ...

Please tell me in a few words if these are the places where I need to update the code, for example to change the min_zoom for paths, instead of 13 to be 12 (I will understand the logic behind the java code as in the past I was a web developer html-php-mysql) I just want to know that I make the modifications in the correct places.

I should get the files in layers folder one by one and adjust each min_zoom setting for all the elements I want to have different values, and if I don't find that specific element in the files I see in the layers folder, I should add it in the /org/openmaptiles/addons/ExtraLayers.java ?

For example I opened all 3 files related to "water" and I could not find any mention regarding spring , this means springs are not defined in this default schema? so I will need to add these elements in the ExtraLayers.java ?

Thank you again.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /