Closed theroggy closed 3 months ago
The nodata values are not being ignored.
The issue is that the type of "mode" is the same as the type of the input raster, i.e. byte. Since there are no pixels with an actual data value, there is no result for "mode". How do you represent "no result" ? If the input raster is a floating point type, you can return NaN. There being no equivalent of NaN for integers, it returns ... the nodata value.
I can see that this is not ideal. It'll take some thought to see how it can be improved.
Maybe return None
?
None exists only in Python, and it's a distinct type from integer. This is all happening in C++.
std::monostate or std::optional?
My example didn't quite show the behaviour with a tiff with scale
and offset
specified, so I updated the code sample above.
TLDR: the scale
and offset
are applied to the nodata value returned.
Fix for both issues available on test PyPI: https://test.pypi.org/project/exactextract/0.2.0.dev241/
It seems that for geotiff files, when the nodata value is not np.nan, nodata is not respected.
Tested with exactextract 0.2.0.dev199 from python
Results of some tests:
EDIT: changed the nodata value so the example with
scale
andoffset
set gives a more interesting result. TLDR: thescale
andoffset
are applied to the nodata value returned.Script to reproduce: