Skip to content

Conversation

@DanSchoppe
Copy link

@DanSchoppe DanSchoppe commented Jul 14, 2025

🚨 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:

  • adds support for an aoi argument to the Reader::tile() method
  • (to support new builds of GDAL) sets VRT param "init_dest_nodata": False to support COGs with a per-dataset mask

@DanSchoppe DanSchoppe changed the base branch from main to 7.8.1-sentera-changes July 18, 2025 15:50
Comment on lines +156 to +162
if nodata is None:
vrt_params.update(
{
"init_dest_nodata": False
}
)
else:
Copy link
Author

@DanSchoppe DanSchoppe Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤷

@DanSchoppe DanSchoppe merged commit 045beb9 into 7.8.1-sentera-changes Aug 15, 2025
@DanSchoppe DanSchoppe deleted the 7.8.1-sentera-changes-dev branch August 15, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants