Closed bdon closed 1 year ago
@Adam-jb what seems to work best is rio-mbtiles
rio mbtiles --zoom-levels 0..11 input.tif output.mbtiles
pmtiles convert output.mbtiles output.pmtiles
@vincentsarago is a port of https://github.com/mapbox/rio-mbtiles a good candidate use case for aiopmtiles?
@bdon I don't think. aiopmtiles
is really just for reading pmtiles not for writing them.
I'm not sure how deep you want to go but I think using gdal
or rio-mbtilesin combination of
pmtiles convert` is simple and should work well.
Just tackled this problem last week, and rio-mbtiles seemed to work the best. Biggest blocker was that other libraries wouldn't make it easy to specify exactly which layers are created. Pain point was just creating the original mbtiles file, all issues appeared during that step.
For some examples,
gdal_translate -co "ZLEVEL=9" input.tif output.mbtiles -of MBTILES
Only created tiles for Z9.
Using gdal2tiles to export to a folder...
gdal2tiles.py \
input.gtiff \
-z 0-9 \
output
Worked as expected, locally at least. When the expanded tiles were zipped up via mb-util
however, only one layer was visible and also drawing at inverted y-coordinates.
Which is to say, I'm sure there's fixes for those quirks above, but rio-mbtiles just works as expected without any wrestling needed. Clean and simple.
Fun example of broken tiles from above:
Remember to sync the tiling scheme!
Options:
--scheme=SCHEME Tiling scheme of the tiles. Default is "xyz" (z/x/y),
other options are "tms" which is also z/x/y but uses a
flipped y coordinate, and "wms" which replicates the
MapServer WMS TileCache directory structure
"z/000/000/x/000/000/y.png"
Options:
-p PROFILE, --profile=PROFILE
Tile cutting profile (mercator,geodetic,raster) -
default 'mercator' (Google Maps compatible)
--xyz Use XYZ tile numbering (OSM Slippy Map tiles) instead
of TMS
I added a section on rio-mbtiles
here: https://protomaps.com/docs/pmtiles#geotiff
Existing options:
gdal_translate
with MBTiles driver >pmtiles convert
: insufficient creation options for low zoom levels