xarray-contrib/xarray-spatial

Spatial analysis algorithms for xarray implemented in numba

What it solves

xarray-spatial solves the problem of doing fast, accurate raster analysis in Python without forcing you to install heavy GIS dependencies like GDAL or GEOS. Rasters are regularly gridded datasets (e.g., GeoTIFFs, elevation models, rainfall maps). The library provides 150+ ready-made functions for common spatial tasks — surface analysis, hydrology, fire behavior, flood modeling, multispectral indices, proximity, classification, pathfinding, and interpolation — so you don't have to write these algorithms yourself.

How it works

It is built on top of xarray, a popular Python package for labeled multi-dimensional arrays. The heavy lifting is done by Numba, which compiles Python code to fast machine code at runtime, and Dask, which lets the same code scale across multiple cores or even a cluster. For GPU users, it also works with CuPy and Numba CUDA. The same function automatically picks the right backend based on the input data type — NumPy, Dask, CuPy, or Dask+CuPy — so you don't need to change your code to go from CPU to GPU. It also includes a native GeoTIFF and Cloud Optimized GeoTIFF (COG) reader/writer, plus reprojection, resampling, and merging tools, all implemented in pure Python and Numba with no C/C++ bindings.

Who it’s for

GIS professionals and anyone working with raster data in Python who need a comprehensive, fast, and scalable spatial analysis toolkit. It's especially useful if you want to avoid the hassle of GDAL/GEOS installation, or if you need to process large rasters that don't fit in memory (via Dask) or want GPU acceleration without leaving Python.

Highlights

  • 150+ spatial functions covering surface, hydrology, fire, flood, multispectral, proximity, classification, pathfinding, and interpolation
  • Automatic backend dispatch across NumPy, Dask, CuPy, and Dask+CuPy — same code, CPU or GPU
  • No GDAL or GEOS dependencies; raster I/O, reprojection, and coordinate handling are pure Python and Numba
  • Native GeoTIFF / Cloud Optimized GeoTIFF reader and writer with support for compression codecs, cloud storage (S3, GCS, Azure), and GPU-accelerated read/write
  • Built-in reprojection with Numba JIT and CUDA kernels for common projections, plus vertical datum and datum shift support
  • Scalable with Dask for out-of-core and parallel processing
  • Extensible with Numba for custom kernels
  • Free and open source (MIT license)

Related

  • Project
  • Project
  • Project
  • Project
  • Project