protomaps / PMTiles

Cloud-optimized + compressed single-file tile archives for vector and raster maps
https://protomaps.com/docs/pmtiles/
BSD 3-Clause "New" or "Revised" License
2.08k stars 123 forks source link

well-tested way to go from raster GeoTiff -> pmtiles #162

Closed bdon closed 1 year ago

bdon commented 1 year ago

Existing options:

bdon commented 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
bdon commented 1 year ago

@vincentsarago is a port of https://github.com/mapbox/rio-mbtiles a good candidate use case for aiopmtiles?

vincentsarago commented 1 year ago

@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 ofpmtiles convert` is simple and should work well.

DylanMoriarty commented 1 year ago

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: Screenshot 2023-04-19 at 10 37 31 AM

tobwen commented 1 year ago

Remember to sync the tiling scheme!

mb-utils

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"

gdal2tiles

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
bdon commented 1 year ago

I added a section on rio-mbtiles here: https://protomaps.com/docs/pmtiles#geotiff