{"id":22995,"library":"xarray-spatial","title":"xarray-spatial","description":"xarray-based spatial analysis tools built on top of xarray, dask, and numba. Current version 0.9.7, released frequently (several minor versions per year).","status":"active","version":"0.9.7","language":"python","source_language":"en","source_url":"https://github.com/xarray-contrib/xarray-spatial","tags":["spatial-analysis","xarray","geospatial","raster","dask","numba"],"install":[{"cmd":"pip install xarray-spatial","lang":"bash","label":"Stable"},{"cmd":"pip install xarray-spatial[complete]","lang":"bash","label":"With extras (recommended for full functionality)"}],"dependencies":[{"reason":"Core data structure","package":"xarray","optional":false},{"reason":"Lazy computation and out-of-core","package":"dask","optional":false},{"reason":"JIT compilation for performance","package":"numba","optional":false},{"reason":"Array operations","package":"numpy","optional":false},{"reason":"Geospatial raster I/O (GeoTIFF, COG)","package":"rioxarray","optional":true},{"reason":"Coordinate transformations","package":"pyproj","optional":true},{"reason":"GPU acceleration via CuPy","package":"cupy","optional":true}],"imports":[{"note":"The library is imported as 'xrspatial', not as a submodule of xarray_spatial.","wrong":"from xarray_spatial import xrspatial","symbol":"xrspatial","correct":"import xrspatial"},{"note":"","wrong":"","symbol":"focal","correct":"from xrspatial import focal"},{"note":"","wrong":"","symbol":"hillshade","correct":"from xrspatial import hillshade"}],"quickstart":{"code":"\nimport xarray as xr\nimport xrspatial\nfrom xrspatial import hillshade\n\n# Create a sample elevation raster\nds = xr.tutorial.load_dataset('air_temperature').isel(time=0)\nelevation = ds['air']\n\n# Compute hillshade\nhs = hillshade(elevation)\nprint(hs)\n","lang":"python","description":"Import the library and compute a hillshade from an xarray DataArray."},"warnings":[{"fix":"Use 'import xrspatial' and functions like 'from xrspatial import focal'.","message":"The top-level import is 'xrspatial', not 'xarray_spatial'. Many users mistakenly try 'import xarray_spatial as xrs' which fails.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass DataArray objects directly; avoid manual conversion to numpy arrays.","message":"As of v0.9.0, many modules (e.g., zonal) now accept xarray DataArrays directly instead of requiring conversion to a specific format. Older code may break if not updated.","severity":"deprecated","affected_versions":">=0.9.0"},{"fix":"Install with 'pip install xarray-spatial[complete]' or install missing extras individually.","message":"If you install without the 'complete' extra, some features like GeoTIFF I/O (via rioxarray) or GPU acceleration (via cupy) will not be available. Missing dependencies raise ImportError at runtime.","severity":"gotcha","affected_versions":"all"},{"fix":"Use .compute() explicitly only when needed; for newer versions, use dask-backed operations.","message":"Dask arrays can cause memory issues if not handled properly. Some functions (e.g., visibility) may silently convert dask arrays to numpy, leading to large memory usage.","severity":"gotcha","affected_versions":"<0.9.7"},{"fix":"Pass an xarray DataArray with a crs attribute as the 'like' parameter.","message":"In v0.9.0, the 'rasterize' function signature changed: the 'like' parameter now expects a DataArray with the same spatial reference. Old code using 'like' with a rasterio dataset may break.","severity":"breaking","affected_versions":">=0.9.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'import xrspatial' or 'from xrspatial import hillshade'.","cause":"Trying to import the wrong name. The correct top-level import is 'xrspatial'.","error":"ModuleNotFoundError: No module named 'xarray_spatial'"},{"fix":"Ensure you have the correct version: 'pip install xarray-spatial[complete]' and import the correct module (e.g., 'from xrspatial import hillshade').","cause":"The function may have been moved or renamed. Check the version documentation.","error":"ImportError: cannot import name 'hillshade' from 'xrspatial'"},{"fix":"Ensure you call the function from xrspatial (e.g., 'hillshade(elevation)') not on the DataArray itself.","cause":"Trying to use a DataArray as a function. Common when mixing up xarray and numpy patterns.","error":"TypeError: 'DataArray' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}