File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1414import xarray as xr
1515from numba import cuda
1616
17- from xrspatial .utils import ArrayTypeFunctionMapping , cuda_args , ngjit
17+ from xrspatial .utils import ArrayTypeFunctionMapping
18+ from xrspatial .utils import cuda_args
19+ from xrspatial .utils import ngjit
20+ from xrspatial .utils import warn_if_unit_mismatch
1821
1922# 3rd-party
2023try :
@@ -262,6 +265,9 @@ def aspect(agg: xr.DataArray,
262265 dtype=float32)
263266 Dimensions without coordinates: y, x
264267 """
268+
269+ warn_if_unit_mismatch (agg )
270+
265271 mapper = ArrayTypeFunctionMapping (
266272 numpy_func = _run_numpy ,
267273 dask_func = _run_dask_numpy ,
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def create_test_raster(
3232 backend = 'numpy' ,
3333 name = 'myraster' ,
3434 dims = ['y' , 'x' ],
35- attrs = {'res' : (0.5 , 0.5 ), 'crs' : 'EPSG: 4326 ' },
35+ attrs = {'res' : (0.5 , 0.5 ), 'crs' : 'EPSG: 5070 ' },
3636 chunks = (3 , 3 )
3737):
3838 raster = xr .DataArray (data , name = name , dims = dims , attrs = attrs )
@@ -42,12 +42,14 @@ def create_test_raster(
4242 if attrs is not None :
4343 if 'res' in attrs :
4444 res = attrs ['res' ]
45+
4546 # set coords for test raster, 2D coords only
4647 raster [dims [0 ]] = np .linspace ((data .shape [0 ] - 1 ) * res [0 ], 0 , data .shape [0 ])
4748 raster [dims [1 ]] = np .linspace (0 , (data .shape [1 ] - 1 ) * res [1 ], data .shape [1 ])
4849
49- raster [dims [0 ]] = np .linspace ((data .shape [0 ] - 1 )/ 2 , 0 , data .shape [0 ])
50- raster [dims [1 ]] = np .linspace (0 , (data .shape [1 ] - 1 )/ 2 , data .shape [1 ])
50+ # assign units to coords
51+ raster [dims [0 ]].attrs ["units" ] = "m"
52+ raster [dims [1 ]].attrs ["units" ] = "m"
5153
5254 if has_cuda_and_cupy () and 'cupy' in backend :
5355 import cupy
You can’t perform that action at this time.
0 commit comments