Description
polygonize() currently checks only raster.ndim != 2. Non-DataArray and non-numeric-dtype inputs raise confusing errors:
polygonize(np.zeros((10, 10))) -> AttributeError on .data etc.
polygonize(xr.DataArray(complex_arr)) -> fails inside numba.
xrspatial/polygonize.py:1623.
Expected behavior
polygonize calls _validate_raster(raster, ...) to surface a clean TypeError / ValueError at the API boundary.
Proposed fix
Replace the raster.ndim != 2 check with _validate_raster(raster, func_name='polygonize', name='raster', ndim=2). Keep the additional shape[0] >= 1 and shape[1] >= 1 guard since _validate_raster does not enforce that.
Description
polygonize()currently checks onlyraster.ndim != 2. Non-DataArray and non-numeric-dtype inputs raise confusing errors:polygonize(np.zeros((10, 10)))->AttributeErroron.dataetc.polygonize(xr.DataArray(complex_arr))-> fails inside numba.xrspatial/polygonize.py:1623.Expected behavior
polygonizecalls_validate_raster(raster, ...)to surface a cleanTypeError/ValueErrorat the API boundary.Proposed fix
Replace the
raster.ndim != 2check with_validate_raster(raster, func_name='polygonize', name='raster', ndim=2). Keep the additionalshape[0] >= 1 and shape[1] >= 1guard since_validate_rasterdoes not enforce that.