7.8.1: Re-introduce aoi argument to Reader::tile() to support clipped tiles#5
Conversation
| if nodata is None: | ||
| vrt_params.update( | ||
| { | ||
| "init_dest_nodata": False | ||
| } | ||
| ) | ||
| else: |
There was a problem hiding this comment.
This is a new change that adds VRT option "init_dest_nodata": False for datasets in which no nodata is specified.
Important context:
We're building against the most recent master GDAL content, not the GDAL version that rasterio usually comes with. As of the time of this writing, that's GDAL commit 92e2427.
/Important context
This change is necessary to accommodate COGs that contain an internal per-dataset mask. Without this change, when I would request a raster tile via TiTiler, GDAL was throwing an error:
Traceback (most recent call last):
File "rasterio/_io.pyx", line 969, in rasterio._io.DatasetReaderBase._read
File "rasterio/_io.pyx", line 199, in rasterio._io.io_multi_band
File "rasterio/_io.pyx", line 205, in rasterio._io.io_multi_band
File "rasterio/_err.pyx", line 325, in rasterio._err.StackChecker.exc_wrap_int
rasterio._err.CPLE_AppDefinedError: IReadBlock failed at X offset 0, Y offset 0: INIT_DEST was set to NO_DATA, but a NoData value was not defined. This warning will become a failure in a future GDAL release.
(NOTE: this was an actual thrown exception from rasterio/GDAL that resulted in failed tile requests, not a warning. I can't explain why the error message seems to incorrectly assert that it's a warning.)
It was surprising to me that INIT_DEST: NO_DATA would be set at all. I want TiTiler + rio-tiler to simply respect the mask configuration of the target dataset rather than bake in some assumption about the target dataset. I think this INIT_DEST: NO_DATA is a result of rio-tiler-supplied VRT param "add_alpha": True, which GDAL is calling out as problematic when the source dataset doesn't have a NODATA value defined.
There was a problem hiding this comment.
CC @vincentsarago. Curious if this makes sense to you, and if it's perhaps a desirable upstream change to rio-tiler for future versions of GDAL — as mentioned in the above comment, this is perhaps an issue thanks to the bleeding-edge build of GDAL I am running against.
There was a problem hiding this comment.
I'm not fully sure to understand the change
in rio-tiler, we do pass nodata and src_nodata to construct the VRT document and init_dest_nodata=True by default so I'm not quite sure why would GDAL raise an error
maybe something changed in GDAL and rasterio is not yet up to date for it 🤷
🚨 Reminder: this is a public repo 🚨
This PR rebases the changes from #2 onto the latest 7.8.1 release of rio-tiler. This work is being done in tandem with SenteraLLC/titiler#6 to modernize the SenteraLLC fork of TiTiler.
More specifically, it:
aoiargument to theReader::tile()method"init_dest_nodata": Falseto support COGs with a per-dataset mask