issues: 1630746106
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1630746106 | I_kwDOAMm_X85hMzX6 | 7645 | encode_cf_variable triggers AttributeError: 'DataArray' object has no attribute '_data' | 8699967 | closed | 0 | 3 | 2023-03-19T02:23:44Z | 2023-03-20T14:21:07Z | 2023-03-20T14:21:06Z | CONTRIBUTOR | What happened?
What did you expect to happen?No error. Minimal Complete Verifiable Example```Python https://github.com/corteva/rioxarray/blob/21284f67db536d9c104aa872ab0bbc261259e59e/test/integration/test_integration_rioxarray.py#L1818-L1844import numpy import xarray import rioxarray test_da = xarray.DataArray( numpy.zeros((5, 5)), dims=("y", "x"), coords={"y": numpy.arange(1, 6), "x": numpy.arange(2, 7)}, ) test_da.values[1, 1] = -1.1 test_nd = test_da.rio.write_nodata(-1.1) test_nd.rio.write_transform( Affine.from_gdal(425047, 3.0, 0.0, 4615780, 0.0, -3.0), inplace=True ) test_nd.rio.write_crs("EPSG:4326", inplace=True) test_nd.rio.to_raster("dtype.tif", dtype=numpy.uint8) ``` MVCE confirmation
Relevant log output```Python rioxarray/raster_writer.py:288: in to_raster data = encode_cf_variable(out_data).values.astype(numpy_dtype) /usr/share/miniconda/envs/test/lib/python3.9/site-packages/xarray/conventions.py:296: in encode_cf_variable var = coder.encode(var, name=name) /usr/share/miniconda/envs/test/lib/python3.9/site-packages/xarray/coding/times.py:690: in encode ) or contains_cftime_datetimes(variable): /usr/share/miniconda/envs/test/lib/python3.9/site-packages/xarray/core/common.py:1818: in contains_cftime_datetimes return _contains_cftime_datetimes(var._data) self = <xarray.DataArray (y: 5, x: 5)> array([[ 0. , 0. , 0. , 0. , 0. ], [ 0. , -1.1, 0. , 0. , 0. ], [... (y) int64 1 2 3 4 5 * x (x) int64 2 3 4 5 6 spatial_ref int64 0 Attributes: _FillValue: -1.1 name = '_data'
/usr/share/miniconda/envs/test/lib/python3.9/site-packages/xarray/core/common.py:276: AttributeError ``` Anything else we need to know?No response EnvironmentThis is the latest version of xarray/numpy (pre-release versions). https://github.com/corteva/rioxarray/actions/runs/4458288974/jobs/7829970587 |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7645/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |