Skip to content

align_and_resize_raster_stack should ensure output rasters have a defined NoData value #476

@claire-simpson

Description

@claire-simpson

When align_and_resize_raster_stack is called on a raster that does not have a NoData value defined and whose extent is smaller than the target bounding box, the function pads the output raster with 0 values. This behavior can silently introduce incorrect data, as these 0 pixels are treated as valid values rather than NoData.

Instead, if an input raster does not have a set NoData value, this function should assign an appropriate one (e.g., using choose_nodata) prior to warping. This ensures that, when warping the raster, any edge pixels (where the input raster didn't overlap the target extent) will be assigned this NoData value (which will then correctly be treated as NoData in downstream tasks). I think it would also be useful to log when an input has no defined NoData value and/or is smaller than the target bounding box.

For more context on this issue see natcap/invest#2392 (comment)

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions