Many population datasets use NODATA pixels for areas outside the modeled domain, e.g. ocean pixels. For the purpose of exactextract these should be considered equivalent to zero.
The following workaround is available in Python using GDAL:
This is not clear in its intent and easy to get wrong. As an alternative, the exactextractr package uses default_weight and default_value arguments to convert NODATA into a constant value.
Similar functionality could be added to exactextract, either by:
1) modifying Raster to have a default_value argument. This would require that all RasterSource implementations in turn accept such a value, and pass it along when constructing Raster objects.
2) modifying RasterStats to take appropriate arguments, so you could call e.g.weighted_mean(default_weight=0). This would be automatically exposed in both the Python bindings and the CLI and would avoid the need to modify RasterSource implementations.
Many population datasets use
NODATA
pixels for areas outside the modeled domain, e.g. ocean pixels. For the purpose ofexactextract
these should be considered equivalent to zero.The following workaround is available in Python using GDAL:
This is not clear in its intent and easy to get wrong. As an alternative, the exactextractr package uses
default_weight
anddefault_value
arguments to convert NODATA into a constant value.Similar functionality could be added to exactextract, either by:
1) modifying
Raster
to have adefault_value
argument. This would require that allRasterSource
implementations in turn accept such a value, and pass it along when constructingRaster
objects. 2) modifyingRasterStats
to take appropriate arguments, so you could call e.g.weighted_mean(default_weight=0)
. This would be automatically exposed in both the Python bindings and the CLI and would avoid the need to modifyRasterSource
implementations.