Issue presented using GDAL called from Python
I have a TIFF file, src.tiff. I want to reproject it and create a COG, dst.tiff. To achieve that, I do the following:
from osgeo import gdal warp_opts = gdal.WarpOptions( dstSRS="EPSG:3857", # comment out this line if you want to have a meta["metadata"]["TILING_SCHEME"]["ZOOM_LEVEL"] value resampleAlg="cubic", dstAlpha=True, format="COG", creationOptions=[ "COMPRESS=DEFLATE", "BLOCKSIZE=512", "TILING_SCHEME=GoogleMapsCompatible", ], ) gdal.Warp("dst.tiff", "src.tiff", options=warp_opts) This produces dst.tiff, a COG. It has overviews, as expected. Here is how I know that:
meta = gdal.Run("raster", "info", input="dst.tiff").Output() print(meta["bands"][0]['overviews']) Output:
[{'size': [1536, 1280]}, {'size': [768, 640]}, {'size': [384, 320]}] However, there is no TILING_SCHEME/ZOOM_LEVEL parameter. I am looking for it:
print(meta["metadata"]["TILING_SCHEME"]["ZOOM_LEVEL"]) I get KeyError: 'TILING_SCHEME'. However, if I uncomment the dstSRS="EPSG:3857" line from gdal.WarpOptions, and rerun gdal.Warp, then
meta = gdal.Run("raster", "info", input="dst.tiff").Output() print(meta["metadata"]["TILING_SCHEME"]["ZOOM_LEVEL"]) returns 13.
Same issue using GDAL called from CLI
This returns null unless I remove -t_srs EPSG:3857 \, in which case I get 13:
gdalwarp -of COG \ -t_srs EPSG:3857 \ -co COMPRESS=DEFLATE \ -co BLOCKSIZE=512 \ -co TILING_SCHEME=GoogleMapsCompatible \ src.tiff dst.tiff gdalinfo dst.tiff -json | jq -r '.metadata.TILING_SCHEME.ZOOM_LEVEL' How can I reproject and have TILING_SCHEME metadata in a COG I produce using GDAL?