Package: xarray-spatial
Latest ReleaseDownloadsLicensePeopleBuild StatusCoverage:round_pushpin: Fast, Accurate Python library for Raster Operations:zap: Extensible withNumba:fast_forward: Scalable withDask:confetti_ball: Free of GDAL / GEOS Dependencies:earth_africa: General-Purpose Spatial Processing, Geared Towards GIS ProfessionalsXarray-Spatial implements common raster analysis functions using Numba and provides an easy-to-install, easy-to-extend codebase for raster analysis.Installation# via pippipinstallxarray-spatial# via condacondainstall-cconda-forgexarray-spatialDownloading our starter examples and dataOnce 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-spatialgrew out of theDatashader project, which provides fast rasterization of vector data (points, lines, polygons, meshes, and rasters) for use with xarray-spatial.xarray-spatialdoes 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, butdocs 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 InputsClassificationNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayEqual Interval✅️✅✅️Natural Breaks✅️️Reclassify✅️✅✅✅Quantile✅️✅✅️FocalNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayApply✅️✅️Hotspots✅️✅️✅️Mean✅️✅️✅️Focal Statistics✅️✅️✅️MultispectralNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayAtmospherically 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✅️️✅️️PathfindingNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayA* Pathfinding✅️ProximityNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayAllocation✅️✅Direction✅️✅Proximity✅️✅Raster to vectorNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayPolygonize✅️SurfaceNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayAspect✅️✅️✅️⚠️Curvature✅️⚠️Hillshade✅️✅️Slope✅️✅️✅️⚠️Terrain Generation✅️✅️✅️Viewshed✅️Perlin Noise✅️✅️✅️Bump Mapping✅️ZonalNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayApply✅️✅️Crop✅️RegionsTrim✅️Zonal Statistics✅️✅️Zonal Cross Tabulate✅️✅️LocalNameNumPy xr.DataArrayDask xr.DataArrayCuPy GPU xr.DataArrayDask GPU xr.DataArrayCell Stats✅️Combine✅️Lesser Frequency✅️Equal Frequency✅️Greater Frequency✅️Lowest Position✅️Highest Position✅️Popularity✅️Rank✅️UsageBasic Patternimportxarrayasxrfromxrspatialimporthillshademy_dataarray=xr.DataArray(...)hillshaded_dataarray=hillshade(my_dataarray)Check out the user guidehere.Dependenciesxarray-spatialcurrently depends on Datashader, but will soon be updated to depend only onxarrayandnumba, while still being able to make use of Datashader output when available.Notes on GDALWithin 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-spatialimplements 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 byxarray-spatialwhere available, while still using GDAL where required for other tasks.CitationCite our code:makepath/xarray-spatial, https://github.com/makepath/xarray-spatial, ©2020-2023.