Skip to content
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

BUG: Remove xarray crs attribute in rio.write_crs (issue #488) #490

Merged
merged 13 commits into from
Mar 30, 2022

Conversation

GCBallesteros
Copy link
Contributor

@snowman2
Copy link
Member

Thanks @GCBallesteros 👍

I see that you added it to set_crs. Would you mind moving it to write_crs ?

@snowman2
Copy link
Member

snowman2 commented Mar 25, 2022

Also, mind adding a simple test around here?

It just needs to have a Dataframe with the crs attribute, call rio.write_crs and check that the crs attribute is gone?

rioxarray/rioxarray.py Outdated Show resolved Hide resolved
@GCBallesteros
Copy link
Contributor Author

A number of tests are failing now due to the removal of the crs attribute. Should I fix them by making use of the rio.crs attribute?

@snowman2
Copy link
Member

A number of tests are failing now due to the removal of the crs attribute. Should I fix them by making use of the rio.crs attribute?

For test_merge_arrays__res and test_merge_arrays I would remove the crs attribute usage in the tests entirely as it will no longer be found.

For test_reproject__grid_mapping I would suggest replacing _get_attr(mda, "crs") with mda.rio.crs and _get_attr(mdc, "crs") with mdc.rio.crs.

On `test_reproject__grid_mapping` the deletion via `_del_attr` of the
crs has also been removed as it shouldn't be there.
Setting `mda.coords["spatial_ref"]` to 0 will make `mda.rio.crs` return
None which then results on an error as we would be asking for
`CRS.from_user_input(None)`.
@GCBallesteros
Copy link
Contributor Author

The problem fixed by commit dd510b5 only happen when opening the files with open_rasterio_engine.

@snowman2
Copy link
Member

I pushed a fix for the scenario when the CRS isn't found by rasterio/GDAL, but can be determined from the attributes by rioxarray.

@snowman2 snowman2 requested a review from justingruca March 30, 2022 14:19
@snowman2 snowman2 changed the title Remove crs after rio crs BUG: Remove xarray crs attribute in rio.write_crs (issue #488) Mar 30, 2022
@snowman2
Copy link
Member

Thanks @GCBallesteros 👍

@snowman2 snowman2 merged commit 8712764 into corteva:master Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xarray.Dataset.reproject doesn't modify the crs attribute
3 participants