Closed przemyslawpluta closed 3 years ago
Running WEBP or PNG without --rgba does not fail but produces image with black tiles:
rio mbtiles -o file.mbtiles -f WEBP --zoom-levels 6..15 file.tif
It looks like rio mbtiles
fails as there is no band 4 alpha in the raster. Solution is to create a RGBA dataset from a RGB dataset with an alpha mask before running command but it would be great for rio mbtiles
to do it automatically if band 4 alpha is not present.
gdal_translate file.tif file-withalphamask.tif -b 1 -b 2 -b 3 -b mask
@przemyslawpluta would you be willing to try the 1.6a1 pre-release? It has two changes that you might profit from. To get it: python -m pip install --pre rio-mbtiles
.
rio mbtiles -o file.mbtiles -f WEBP --zoom-levels 6..15 --include-empty-tiles --rgba file.tif
will automatically create an alpha channel and include empty transparent tiles in file.mbtiles instead of excluding them (the default).
@sgillies thanks for an update ... it's great to see how efficient it is but ...
... just run another test against pre-release version and outcome seems to produce tiles with which seems to indicate that alpha mask is not covering entire raster ... places which should be black appears to be cut out. Unfortunately mapbox still returns 404 even with --include-empty-tiles
.
rio mbtiles -o file.mbtiles -f WEBP --zoom-levels 6..15 --co QUALITY=95 --include-empty-tiles --rgba file.tif
@przemyslawpluta thanks for trying it out! I'll come up with a fix for the holes.
Version 1.5 of rio-mbtiles would exclude empty tiles from the mbtiles database. For example, if your source dataset had an L-shaped region of valid pixels within a rectangular raster, tiles that were entirely outside the valid data region would be excluded from the mbtiles database. And GL JS would report an error, which could be surprising. However, there's nothing rio-mbtiles can do about GL JS views beyond the extent of the tileset, you have to expect to see 404 errors in that case.
@sgillies sounds good
Version 1.6a2 on PyPI now exports images with no holes.
@sgillies just tested 1.6a2 and it looks good. Thanks.
Running:
results with error: