Skip to main content
Latest Release
pypi version
Downloads
PyPI downloads per month
License MIT People GitHub contributors
Build Status Coverage

History of OS GIS Timeline


title

:round_pushpin: Fast, Accurate Python library for Raster Operations

:zap: Extensible with Numba

:fast_forward: Scalable with Dask

:confetti_ball: Free of GDAL / GEOS Dependencies

:earth_africa: General-Purpose Spatial Processing, Geared Towards GIS Professionals


Xarray-Spatial implements common raster analysis functions using Numba and provides an easy-to-install, easy-to-extend codebase for raster analysis.

Installation

# via pip
pip install xarray-spatial

# via conda
conda install -c conda-forge xarray-spatial

Downloading our starter examples and data

Once you have xarray-spatial installed in your environment, you can use one of the following in your terminal (with the environment active) to download our examples and/or sample data into your local directory.

xrspatial examples : Download the examples notebooks and the data used.

xrspatial copy-examples : Download the examples notebooks but not the data. Note: you won't be able to run many of the examples.

xrspatial fetch-data : Download just the data and not the notebooks.

In all the above, the command will download and store the files into your current directory inside a folder named 'xrspatial-examples'.

xarray-spatial grew out of the Datashader project, which provides fast rasterization of vector data (points, lines, polygons, meshes, and rasters) for use with xarray-spatial.

xarray-spatial does not depend on GDAL / GEOS, which makes it fully extensible in Python but does limit the breadth of operations that can be covered. xarray-spatial is meant to include the core raster-analysis functions needed for GIS developers / analysts, implemented independently of the non-Python geo stack.

Our documentation is still under construction, but docs can be found here.

Raster-huh?

Rasters are regularly gridded datasets like GeoTIFFs, JPGs, and PNGs.

In the GIS world, rasters are used for representing continuous phenomena (e.g. elevation, rainfall, distance), either directly as numerical values, or as RGB images created for humans to view. Rasters typically have two spatial dimensions, but may have any number of other dimensions (time, type of measurement, etc.)

Supported Spatial Functions with Supported Inputs


Classification

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Equal Interval ✅️ ✅ ✅ ️
Natural Breaks ✅️ ️
Reclassify ✅️ ✅ ✅ ✅
Quantile ✅️ ✅ ✅ ️

Focal

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Apply ✅️ ✅️
Hotspots ✅️ ✅️ ✅️
Mean ✅️ ✅️ ✅️
Focal Statistics ✅️ ✅️ ✅️

Multispectral

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Atmospherically Resistant Vegetation Index (ARVI) ✅️ ✅️ ✅️ ✅️
Enhanced Built-Up and Bareness Index (EBBI) ✅️ ✅️ ✅️ ✅️
Enhanced Vegetation Index (EVI) ✅️ ✅️ ✅️ ✅️
Green Chlorophyll Index (GCI) ✅️ ✅️ ✅️ ✅️
Normalized Burn Ratio (NBR) ✅️ ✅️ ✅️ ✅️
Normalized Burn Ratio 2 (NBR2) ✅️ ✅️ ✅️ ✅️
Normalized Difference Moisture Index (NDMI) ✅️ ✅️ ✅️ ✅️
Normalized Difference Vegetation Index (NDVI) ✅️ ✅️ ✅️ ✅️
Soil Adjusted Vegetation Index (SAVI) ✅️ ✅️ ✅️ ✅️
Structure Insensitive Pigment Index (SIPI) ✅️ ✅️ ✅️ ✅️
True Color ✅️ ️ ✅️ ️

Pathfinding

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
A* Pathfinding ✅️

Proximity

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Allocation ✅️ ✅
Direction ✅️ ✅
Proximity ✅️ ✅

Raster to vector

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Polygonize ✅️

Surface

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Aspect ✅️ ✅️ ✅️ ⚠️
Curvature ✅️ ⚠️
Hillshade ✅️ ✅️
Slope ✅️ ✅️ ✅️ ⚠️
Terrain Generation ✅️ ✅️ ✅️
Viewshed ✅️
Perlin Noise ✅️ ✅️ ✅️
Bump Mapping ✅️

Zonal

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Apply ✅️ ✅️
Crop ✅️
Regions
Trim ✅️
Zonal Statistics ✅️ ✅️
Zonal Cross Tabulate ✅️ ✅️

Local

Name NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Cell Stats ✅️
Combine ✅️
Lesser Frequency ✅️
Equal Frequency ✅️
Greater Frequency ✅️
Lowest Position ✅️
Highest Position ✅️
Popularity ✅️
Rank ✅️

Usage

Basic Pattern
import xarray as xr
from xrspatial import hillshade

my_dataarray = xr.DataArray(...)
hillshaded_dataarray = hillshade(my_dataarray)

Check out the user guide here.


title title

Dependencies

xarray-spatial currently depends on Datashader, but will soon be updated to depend only on xarray and numba, while still being able to make use of Datashader output when available.

title

Notes on GDAL

Within the Python ecosystem, many geospatial libraries interface with the GDAL C++ library for raster and vector input, output, and analysis (e.g. rasterio, rasterstats, geopandas). GDAL is robust, performant, and has decades of great work behind it. For years, off-loading expensive computations to the C/C++ level in this way has been a key performance strategy for Python libraries (obviously...Python itself is implemented in C!).

However, wrapping GDAL has a few drawbacks for Python developers and data scientists:

  • GDAL can be a pain to build / install.
  • GDAL is hard for Python developers/analysts to extend, because it requires understanding multiple languages.
  • GDAL's data structures are defined at the C/C++ level, which constrains how they can be accessed from Python.

With the introduction of projects like Numba, Python gained new ways to provide high-performance code directly in Python, without depending on or being constrained by separate C/C++ extensions. xarray-spatial implements algorithms using Numba and Dask, making all of its source code available as pure Python without any "black box" barriers that obscure what is going on and prevent full optimization. Projects can make use of the functionality provided by xarray-spatial where available, while still using GDAL where required for other tasks.

Citation

Cite our code:

makepath/xarray-spatial, https://github.com/makepath/xarray-spatial, ©2020-2024.

Metadata

Release files for xarray-spatial 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xarray-spatial 0.4.0
File Size Uploaded
xarray_spatial-0.4.0.tar.gz 70.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for xarray-spatial 0.4.0
File Interpreter ABI Platform
xarray_spatial-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 72.3 MB

Release files / xarray_spatial-0.4.0.tar.gz

Download URL xarray_spatial-0.4.0.tar.gz
Size 70.3 MB
Tags Source
SHA-256 checksum
How to use checksums
cc2da7630acc49b1fefbeb3f4509c15d6eea93d12938ee8f617395a70a6a2da2
BLAKE2b-256 checksum
How to use checksums
3d95986aa38c585abe6cec85fca260c6c2902a415f99d937bf0cc362af71e6fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release files / xarray_spatial-0.4.0-py3-none-any.whl

Download URL xarray_spatial-0.4.0-py3-none-any.whl
Size 2.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6c207c90142f3fbba142e67bfd7f69767246aba6146aca9e130581b35799c9df
BLAKE2b-256 checksum
How to use checksums
f3728cc5d33d86260e030cd703a5b5021656d1c49066cad710825f0b23428ef6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release history Release notifications | RSS feed

0.10.9

2 release files

0.10.8

2 release files

0.10.7

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.9

2 release files

0.9.8

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

This release

0.4.0 This release

2 release files

0.3.7

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.5

1 release file

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page