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

CRS set on Dataset does not persist for DataArrays obtained by selecting data variable #356

Closed
vidurmithal opened this issue Jun 14, 2021 · 3 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@vidurmithal
Copy link

Code Sample

da1 = xr.DataArray(np.arange(10*10).reshape(10, 10), [("x", np.linspace(70,80,10)), ("y", np.linspace(20,30,10))], name='var_1')
da2 = xr.DataArray(np.arange(10*10).reshape(10, 10), [("x", np.linspace(70,80,10)), ("y", np.linspace(20,30,10))], name='var_2')

ds = xr.merge([da1,da2])

ds = ds.rio.set_crs('epsg:4326')

print('Dataset CRS: {}'.format(ds.rio.crs))
print('DataArray 1 CRS: {}'.format(ds['var_1'].rio.crs))
print('DataArray 2 CRS: {}'.format(ds['var_2'].rio.crs))

Problem description

The CRS set on a Dataset using .rio.set_crs() does not persist to a DataArray obtained by selecting individual variables from the Dataset. Printing the CRS of the Dataset gives the previously set CRS, but printing the CRS of the DataArray gives None.

Expected Output

The CRS set on a Dataset should also apply to DataArrays of individual variables. Printing DataArray.rio.crs should give the set CRS, EPSG:4326 in this case.

Environment Information

rioxarray (0.1.1) deps:
  rasterio: 1.1.0
    xarray: 0.16.2
      GDAL: 3.0.2

Other python deps:
     scipy: 1.4.1
    pyproj: 2.6.0

System:
   python: 3.7.7 (default, Mar 23 2020, 22:36:06)  [GCC 7.3.0]
   machine: Linux-5.4.89+-x86_64-with-debian-bullseye-sid

Installation method

PyPi

@vidurmithal vidurmithal added the bug Something isn't working label Jun 14, 2021
@snowman2
Copy link
Member

We recommend using rio.write_crs as it persists better.

@snowman2
Copy link
Member

Related #252

@snowman2 snowman2 added the wontfix This will not be worked on label Jun 14, 2021
@snowman2
Copy link
Member

snowman2 commented Jun 2, 2022

For those finding this issue, I recommend reading the Getting Started: Introductory Information references for rioxarray. The Coordinare Reference System Management section is relevant for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants