-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve nan in comparisons #527
Comments
created minimal reproduction use case here: Note how the nan from the mask-polygon results in different outputs:
|
Numpy gives a boolean result when comparing with nan (JavaScript does the same). import numpy as np
print(np.__version__) # 1.24.4
print(np.nan == 3) # False
print(np.nan != 3) # True
print(np.nan < 3) # False
print(np.nan <= 3) # False
print(np.nan > 3) # False
print(np.nan >= 3) # False Maybe we could pass the nan behaviour as an option? For example: |
There might be more wrong than just that. Reading up a bit more... |
@EmileSonneveld please have a look at this, since it's highly related: https://github.com/Open-EO/openeo-processes-dask/blob/main/docs/decisions/handle-nodata-in-rastercubes.md |
Exporting a signed byte layer results a tiff or nc makes a file that gets interpreted as a unsigned byte image by Q-gis and rasterio. An example for this bug is visible in an auto test here: https://jenkins.vgt.vito.be/job/openEO/job/openeo-geotrellis-extensions/job/develop/781/execution/node/3/ws/openeo-geotrellis/outFiltered.tif (Tiles at the left are 128) It looks like when exporting a 'bit' layer to netcdf, it ends up as a byte layer, and probably triggering this bug. Explaining the 128 values instead of nodata in the first example |
As a workaround, it is already possible to preserve nan like this: snowmap = ndsi.apply(lambda x: if_(is_nan(x), x, x > 0.4)) |
GDAL >= 3.7 supports signed bytes: https://github.com/OSGeo/gdal/blob/7d5725c91eafc9fb0fc2c3d4136a466004648d14/gcore/gdal.h#L67C55-L67C55 (From May 2023) Until GDAL 3.7< is used everywhere, int8 could cause overflow issues on many locations. |
The openEO processes explicitly mention nan-support for
gt
,lt
,gte
, ...:So the output of such a process could be
true
,false
and no-data.I think we work purely binary and cast (?) no-data to
false
(brought up here by @clausmichele : https://discuss.eodc.eu/t/boolean-mask-and-mask-polygon-issue/626)
The text was updated successfully, but these errors were encountered: