Skip to content

Commit 8b99213

Browse files
authored
Hot fix get_dataarray_resolution (#162)
* res attribute can be an array * get resolution: check if res attribute an array-like object
1 parent 17f6b04 commit 8b99213

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

xrspatial/utils.py

100644100755
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,9 @@ def calc_res(raster):
8686

8787
def get_dataarray_resolution(agg: xr.DataArray):
8888

89-
if not agg.attrs.get('res'):
90-
raise ValueError('input xarray must have `res` attr.')
91-
9289
# get cellsize out from 'res' attribute
9390
cellsize = agg.attrs.get('res')
94-
if isinstance(cellsize, tuple) and len(cellsize) == 2 \
91+
if isinstance(cellsize, (tuple, np.ndarray, list)) and len(cellsize) == 2 \
9592
and isinstance(cellsize[0], (int, float)) \
9693
and isinstance(cellsize[1], (int, float)):
9794
cellsize_x, cellsize_y = cellsize

0 commit comments

Comments
 (0)