Skip to content

xarray-contrib/xvec

Repository files navigation

Vector data cubes for Xarray

In geospatial analysis, data cubes can be of two sorts. The first is a raster data cube, typically represented by an Xarray DataArray indexed either by x or y dimensions or latitude and longitude. The second is a vector data cube, which is an n-D array that has either at least one dimension indexed by a 2-D array of vector geometries (Pebesma, 2022) or contains geometries as variables (e.g. moving features or time-evolving shapes), possibly both.

We can distinguish between two types of geometries in a DataArray or Dataset:

  • coordinate geometry - an array (typically one dimensional) is used as coordinates along one or more dimensions. A typical example would be an outcome of zonal statistics of a multi-dimensional raster, avoiding the need for flattenning of the array to a data frame.
  • variable geometry - an array (typicially multi-dimensional) is used as a variable within a DataArray. This may encode evolving shapes of lava flows in time, trajectories, or growth of city limits.

The Xvec package brings support for both of these to the Xarray ecosystem. It uses Shapely package, allowing a seamless interface between Xvec and GeoPandas. See this post by Edzer Pebesma on an introduction of the concept of coordinate geometry or introduction page in Xvec documentation.

Project status

The project is in the early stage of development and its API may still change.

Installing

You can install Xvec from PyPI using pip or from conda-forge using mamba or conda:

pip install xvec

Or (recommended):

mamba install xvec -c conda-forge

Development version

The development version can be installed from GitHub.

pip install git+https://github.com/xarray-contrib/xvec.git

We recommend installing its dependencies using mamba or conda before.

mamba install xarray shapely pyproj -c conda-forge