Skip to main content

xarray-based spatial analysis tools

Project description

Latest Release
pypi version conda-forge version
Downloads
PyPI downloads per month conda-forge downloads
License MIT People GitHub contributors
Build Status Coverage

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

โœ… = native backend ย ย  ๐Ÿ”„ = accepted (CPU fallback)


Classification

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Box Plot Classifies values into bins based on box plot quartile boundaries PySAL mapclassify โœ…๏ธ โœ… โœ… ๐Ÿ”„
Equal Interval Divides the value range into equal-width bins PySAL mapclassify โœ…๏ธ โœ… โœ… โœ…
Head/Tail Breaks Classifies heavy-tailed distributions using recursive mean splitting PySAL mapclassify โœ…๏ธ โœ… ๐Ÿ”„ ๐Ÿ”„
Maximum Breaks Finds natural groupings by maximizing differences between sorted values PySAL mapclassify โœ…๏ธ โœ… ๐Ÿ”„ ๐Ÿ”„
Natural Breaks Optimizes class boundaries to minimize within-class variance (Jenks) Jenks 1967, PySAL โœ…๏ธ โœ… ๐Ÿ”„ ๐Ÿ”„
Percentiles Assigns classes based on user-defined percentile breakpoints PySAL mapclassify โœ…๏ธ โœ… โœ… ๐Ÿ”„
Quantile Distributes values into classes with equal observation counts PySAL mapclassify โœ…๏ธ โœ… โœ… ๐Ÿ”„
Reclassify Remaps pixel values to new classes using a user-defined lookup PySAL mapclassify โœ…๏ธ โœ… โœ… โœ…
Std Mean Classifies values by standard deviation intervals from the mean PySAL mapclassify โœ…๏ธ โœ… โœ… โœ…

Diffusion

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Diffuse Runs explicit forward-Euler diffusion on a 2D scalar field Standard (heat equation) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Focal

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Apply Applies a custom function over a sliding neighborhood window Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Hotspots Identifies statistically significant spatial clusters using Getis-Ord Gi* Getis & Ord 1992 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Emerging Hotspots Classifies time-series hot/cold spot trends using Gi* and Mann-Kendall Getis & Ord 1992, Mann 1945 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Mean Computes the mean value within a sliding neighborhood window Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Focal Statistics Computes summary statistics over a sliding neighborhood window Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Bilateral Feature-preserving smoothing via bilateral filtering Tomasi & Manduchi 1998 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
GLCM Texture Computes Haralick GLCM texture features over a sliding window Haralick et al. 1973 โœ…๏ธ โœ…๏ธ ๐Ÿ”„ ๐Ÿ”„

Morphological

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Erode Morphological erosion (local minimum over structuring element) Standard (morphology) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Dilate Morphological dilation (local maximum over structuring element) Standard (morphology) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Opening Erosion then dilation (removes small bright features) Standard (morphology) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Closing Dilation then erosion (fills small dark gaps) Standard (morphology) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Fire

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
dNBR Differenced Normalized Burn Ratio (pre minus post NBR) USGS โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
RdNBR Relative dNBR normalized by pre-fire vegetation density USGS โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Burn Severity Class USGS 7-class burn severity from dNBR thresholds USGS โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Fireline Intensity Byram's fireline intensity from fuel load and spread rate (kW/m) Byram 1959 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Flame Length Flame length derived from fireline intensity (m) Byram 1959 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Rate of Spread Simplified Rothermel spread rate with Anderson 13 fuel models (m/min) Rothermel 1972, Anderson 1982 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
KBDI Keetch-Byram Drought Index single time-step update (0-800 mm) Keetch & Byram 1968 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Multispectral

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Atmospherically Resistant Vegetation Index (ARVI) Vegetation index resistant to atmospheric effects using blue band correction Kaufman & Tanre 1992 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Enhanced Built-Up and Bareness Index (EBBI) Highlights built-up areas and barren land from thermal and SWIR bands As-syakur et al. 2012 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Enhanced Vegetation Index (EVI) Enhanced vegetation index reducing soil and atmospheric noise Huete et al. 2002 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Green Chlorophyll Index (GCI) Estimates leaf chlorophyll content from green and NIR reflectance Gitelson et al. 2003 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Normalized Burn Ratio (NBR) Measures burn severity using NIR and SWIR band difference USGS Landsat โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Normalized Burn Ratio 2 (NBR2) Refines burn severity mapping using two SWIR bands USGS Landsat โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Normalized Difference Moisture Index (NDMI) Detects vegetation moisture stress from NIR and SWIR reflectance USGS Landsat โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Normalized Difference Water Index (NDWI) Maps open water bodies using green and NIR band difference McFeeters 1996 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Modified Normalized Difference Water Index (MNDWI) Detects water in urban areas using green and SWIR bands Xu 2006 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Normalized Difference Vegetation Index (NDVI) Quantifies vegetation density from red and NIR band difference Rouse et al. 1973 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Soil Adjusted Vegetation Index (SAVI) Vegetation index with soil brightness correction factor Huete 1988 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Structure Insensitive Pigment Index (SIPI) Estimates carotenoid-to-chlorophyll ratio for plant stress detection Penuelas et al. 1995 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
True Color Composites red, green, and blue bands into a natural color image Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Multivariate

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Mahalanobis Distance Measures statistical distance from a multi-band reference distribution, accounting for band correlations Mahalanobis 1936 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Pathfinding

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
A* Pathfinding Finds the least-cost path between two cells on a cost surface Hart et al. 1968 โœ…๏ธ โœ… ๐Ÿ”„ ๐Ÿ”„
Multi-Stop Search Routes through N waypoints in sequence, with optional TSP reordering Custom โœ…๏ธ โœ… ๐Ÿ”„ ๐Ÿ”„

Proximity

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Allocation Assigns each cell to the identity of the nearest source feature Standard (Dijkstra) โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Balanced Allocation Partitions a cost surface into territories of roughly equal cost-weighted area Custom โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Cost Distance Computes minimum accumulated cost to the nearest source through a friction surface Standard (Dijkstra) โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Least-Cost Corridor Identifies zones of low cumulative cost between two source locations Standard (Dijkstra) โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Direction Computes the direction from each cell to the nearest source feature Standard โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Proximity Computes the distance from each cell to the nearest source feature Standard โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Surface Distance Computes distance along the 3D terrain surface to the nearest source Standard (Dijkstra) โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Surface Allocation Assigns each cell to the nearest source by terrain surface distance Standard (Dijkstra) โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ
Surface Direction Computes compass direction to the nearest source by terrain surface distance Standard (Dijkstra) โœ…๏ธ โœ… โœ…๏ธ โœ…๏ธ

Raster / Vector Conversion

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Polygonize Converts contiguous regions of equal value into vector polygons Standard (CCL) โœ…๏ธ โœ…๏ธ โœ…๏ธ ๐Ÿ”„
Contours Extracts elevation contour lines (isolines) from a raster surface Standard (marching squares) โœ…๏ธ โœ…๏ธ ๐Ÿ”„ ๐Ÿ”„
Rasterize Rasterizes vector geometries (polygons, lines, points) from a GeoDataFrame Standard (scanline, Bresenham) โœ…๏ธ โœ…๏ธ

Surface

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Aspect Computes downslope direction of each cell in degrees Horn 1981 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Curvature Measures rate of slope change (concavity/convexity) at each cell Zevenbergen & Thorne 1987 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Hillshade Simulates terrain illumination from a given sun angle and azimuth GDAL gdaldem โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Roughness Computes local relief as max minus min elevation in a 3ร—3 window GDAL gdaldem โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Sky-View Factor Measures the fraction of visible sky hemisphere at each cell Zakek et al. 2011 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Slope Computes terrain gradient steepness at each cell in degrees Horn 1981 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Terrain Generation Generates synthetic terrain from fBm or ridged fractal noise with optional domain warping, Worley blending, and hydraulic erosion Custom (fBm) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
TPI Computes Topographic Position Index (center minus mean of neighbors) Weiss 2001 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
TRI Computes Terrain Ruggedness Index (local elevation variation) Riley et al. 1999 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Landforms Classifies terrain into 10 landform types using the Weiss (2001) TPI scheme Weiss 2001 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Viewshed Determines visible cells from a given observer point on terrain GRASS GIS r.viewshed โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Min Observable Height Finds the minimum observer height needed to see each cell (experimental) Custom โœ…๏ธ
Perlin Noise Generates smooth continuous random noise for procedural textures Perlin 1985 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Worley Noise Generates cellular (Voronoi) noise returning distance to the nearest feature point Worley 1996 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Hydraulic Erosion Simulates particle-based water erosion to carve valleys and deposit sediment Custom โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Bump Mapping Adds randomized bump features to simulate natural terrain variation Custom โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Hydrology

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Flow Direction (D8) Computes D8 flow direction from each cell toward the steepest downhill neighbor O'Callaghan & Mark 1984 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Flow Direction (Dinf) Computes D-infinity flow direction as a continuous angle toward the steepest downslope facet Tarboton 1997 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Flow Direction (MFD) Partitions flow to all downslope neighbors with an adaptive exponent (Qin et al. 2007) Qin et al. 2007 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Flow Accumulation (D8) Counts upstream cells draining through each cell in a D8 flow direction grid Jenson & Domingue 1988 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Flow Accumulation (MFD) Accumulates upstream area through all MFD flow paths weighted by directional fractions Qin et al. 2007 โœ…๏ธ โœ…๏ธ โœ…๏ธ ๐Ÿ”„
Watershed Labels each cell with the pour point it drains to via D8 flow direction Standard (D8 tracing) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Basins Delineates drainage basins by labeling each cell with its outlet ID Standard (D8 tracing) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Stream Order Assigns Strahler or Shreve stream order to cells in a drainage network Strahler 1957, Shreve 1966 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Stream Order (Dinf) Strahler/Shreve stream ordering on D-infinity flow direction grids Tarboton 1997 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Stream Order (MFD) Strahler/Shreve stream ordering on MFD fraction grids Freeman 1991 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Stream Link Assigns unique IDs to each stream segment between junctions Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Stream Link (Dinf) Stream link segmentation on D-infinity flow direction grids Tarboton 1997 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Stream Link (MFD) Stream link segmentation on MFD fraction grids Freeman 1991 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Snap Pour Point Snaps pour points to the highest-accumulation cell within a search radius Custom โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Flow Path Traces downstream flow paths from start points through a D8 direction grid Standard (D8 tracing) โœ…๏ธ โœ…๏ธ ๐Ÿ”„ ๐Ÿ”„
HAND Computes Height Above Nearest Drainage by tracing D8 flow to the nearest stream cell Nobre et al. 2011 โœ…๏ธ โœ…๏ธ ๐Ÿ”„ ๐Ÿ”„
TWI Topographic Wetness Index: ln(specific catchment area / tan(slope)) Beven & Kirkby 1979 โœ…๏ธ โœ…๏ธ โœ…๏ธ ๐Ÿ”„

Flood

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Flood Depth Computes water depth above terrain from a HAND raster and water level Standard (HAND-based) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Inundation Produces a binary flood/no-flood mask from a HAND raster and water level Standard (HAND-based) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Curve Number Runoff Estimates runoff depth from rainfall using the SCS/NRCS curve number method SCS/NRCS โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Travel Time Estimates overland flow travel time via simplified Manning's equation Manning 1891 โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Interpolation

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
IDW Inverse Distance Weighting from scattered points to a raster grid Standard (IDW) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Kriging Ordinary Kriging with automatic variogram fitting (spherical, exponential, gaussian) Standard (ordinary kriging) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Spline Thin Plate Spline interpolation with optional smoothing Standard (TPS) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ

Zonal

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Apply Applies a custom function to each zone in a classified raster Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Crop Extracts the bounding rectangle of a specific zone Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Regions Identifies connected regions of non-zero cells Standard (CCL) โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Trim Removes nodata border rows and columns from a raster Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ โœ…๏ธ
Zonal Statistics Computes summary statistics for a value raster within each zone Standard โœ…๏ธ โœ…๏ธ โœ…๏ธ ๐Ÿ”„
Zonal Cross Tabulate Cross-tabulates agreement between two categorical rasters Standard โœ…๏ธ โœ…๏ธ ๐Ÿ”„ ๐Ÿ”„

Utilities

Name Description Source NumPy xr.DataArray Dask xr.DataArray CuPy GPU xr.DataArray Dask GPU xr.DataArray
Preview Downsamples a raster to target pixel dimensions for visualization Custom โœ…๏ธ โœ…๏ธ โœ…๏ธ ๐Ÿ”„

Usage

Quick Start

Importing xrspatial registers an .xrs accessor on DataArrays and Datasets, giving you tab-completable access to every spatial operation:

import numpy as np
import xarray as xr
import xrspatial

# Create or load a raster
elevation = xr.DataArray(np.random.rand(100, 100) * 1000, dims=['y', 'x'])

# Surface analysis โ€” call operations directly on the DataArray
slope = elevation.xrs.slope()
hillshaded = elevation.xrs.hillshade(azimuth=315, angle_altitude=45)
aspect = elevation.xrs.aspect()

# Classification
classes = elevation.xrs.equal_interval(k=5)
breaks = elevation.xrs.natural_breaks(k=10)

# Proximity
distance = elevation.xrs.proximity(target_values=[1])

# Multispectral โ€” call on the NIR band, pass other bands as arguments
nir = xr.DataArray(np.random.rand(100, 100), dims=['y', 'x'])
red = xr.DataArray(np.random.rand(100, 100), dims=['y', 'x'])
blue = xr.DataArray(np.random.rand(100, 100), dims=['y', 'x'])

vegetation = nir.xrs.ndvi(red)
enhanced_vi = nir.xrs.evi(red, blue)
Dataset Support

The .xrs accessor works on Datasets too. Single-input functions apply the operation to each data variable. Multi-input functions (multispectral indices) accept string kwargs that map band aliases to variable names:

ds = xr.Dataset({'band_4': red, 'band_5': nir})

# Single-input: slope computed for each variable
slope_ds = ds.xrs.slope()

# Multi-input: map variable names to band parameters
ndvi_result = ds.xrs.ndvi(nir='band_5', red='band_4')
Function Import Style

All operations are also available as standalone functions if you prefer explicit imports:

from xrspatial import hillshade, slope, ndvi

hillshaded = hillshade(elevation)
slope_result = slope(elevation)
vegetation = ndvi(nir, red)

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 this code:

xarray-contrib/xarray-spatial, https://github.com/xarray-contrib/xarray-spatial, ยฉ2020-2026.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xarray_spatial-0.9.2.tar.gz (97.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xarray_spatial-0.9.2-py3-none-any.whl (17.1 MB view details)

Uploaded Python 3

File details

Details for the file xarray_spatial-0.9.2.tar.gz.

File metadata

  • Download URL: xarray_spatial-0.9.2.tar.gz
  • Upload date:
  • Size: 97.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xarray_spatial-0.9.2.tar.gz
Algorithm Hash digest
SHA256 3bcad0b7d469552cb86a955da76fb8f349a74283d288c4c63e319d92b88b8d3b
MD5 2e41b97d03fa682ec9d9ca530ed88b8b
BLAKE2b-256 c18dc15bc62dcb329dbf95d6cb5d3b122493843d2343dbeda61258a60aeaeb37

See more details on using hashes here.

File details

Details for the file xarray_spatial-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: xarray_spatial-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xarray_spatial-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e418ecf608311b67cea7d4a31526625e929e0220fba749e11ede28cf88aa01d8
MD5 3853170e02dbf679846769791052ed92
BLAKE2b-256 8f35ab964b7d862546f72e62760a1576445f5f171a3a010f7db8abaa784d2396

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page