-
Notifications
You must be signed in to change notification settings - Fork 85
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
Unexpected behaviour when modifying coords with assign_coords
#825
Comments
With the change in coordinates, your dx/dy are no longer evenly spaced:
After saving the raster, the new coords are again evenly spaced: # Save
da.rio.to_raster("tmp2.tif")
# Reload
da = rioxarray.open_rasterio("tmp2.tif")
print("Modified values after saving and reloading", da.x.values[:5])
print("DX", da.x.values[:5]-da.x.values[1:6])
|
Thank you for the response, @snowman2! Now, I understand what's going on. Actually, my use case is like the following:
|
I recommend referring to Lines 848 to 891 in fa35e91
In that code, it only adds coordinates for one of the data arrays and then the other data arrays in the dataset inherit the coordinates. |
Thank you for the reference, @snowman2, but I couldn't fully understand what you are trying to convey. I have multiple clusters of files where, in each cluster, coordinates are very similar, with just floating point differences. I'd appreciate a lot if you could provide a code/pseudo-code of how to achieve this. |
this sounds related to https://discourse.pangeo.io/t/example-which-highlights-the-limitations-of-netcdf-style-coordinates-for-large-geospatial-rasters/4140 there's a draft pr in xarray with suggestions on how rioxarray could be changed to not materialize coordinates and introduce floating point imprecision pydata/xarray#9543 |
Code Sample, a copy-pastable example if possible
Output
Expected Output
Environment Information
Installed fresh in Google colab with
pip install rioxarray
Question
If this is not a recommended way to modify the coordinates, please help me with the recommended way.
The text was updated successfully, but these errors were encountered: