-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Losing data when add a raster to a dataset #5075
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
Comments
Please could you create a minimally reproducible example, as per the issue template? |
All do you need is on the first linked issue, so here. You can find QGIS project with data example. |
the issue is that the code example you gave both there and here does not directly use Without looking at the data I can't confirm, but I suspect this is a alignment issue. If so, we do have a open PR (not merged, yet, unfortunately) which added a tolerance kwarg to |
Below my code
Here there are two netCDF with output data. |
could you also show a = xr.open_dataset("out_grid_process_value.nc")
b = xr.open_dataset("rasterized_vector.nc")
xr.testing.assert_equal(a[["id"]], b) shows that the coordinates are equal so that's not the issue. |
Similar issue here: corteva/rioxarray#298 Reproducible example in the issue ^^ |
For the original post for this issue ref:
Looks like there is a tiny difference in decimal precision. |
Similarly at corteva/rioxarray#298 (comment) np.abs(resampled.x.values - da2.x.values).max(), np.abs(resampled.y.values - da2.y.values).max()
|
Also related: corteva/rioxarray#332 |
I think it would be nice for xarray to have a "close enough" option where a certain number of decimal places is enough to consider them equal. Is there an issue somewhere where this is under consideration or is there an option already in existence that I missed? |
if I understand the issue correctly this will be fixed by the index refactor (see #4489 (comment)) |
Yes, the alignment stuff in there should do the trick. |
It looks like this was fixed somewhere before xarray 2024.10.0. At least the example in #5075 (comment) works now as expected. Can you confirm @snowman2? Then we could close this issue. |
rioxarray added workarounds for it to work. Not sure if we can verify it using rioxarray or geocube. Will need an example that doesn't depend on those libraries to verify. |
As I mentioned here, when I add a raster inside a geocube are produced a lot of nodata.
After a test @snowman2 has indicates that this is a possible bug of xarray libraries.
The text was updated successfully, but these errors were encountered: