xvec.GeometryIndex#

class xvec.GeometryIndex(index, crs=None)#

An CRS-aware, Xarray-compatible index for vector geometries.

This index can be set from any 1-dimensional coordinate of (shapely 2.0) shapely.Geometry elements.

It provides all the basic functionality of an xarray.indexes.PandasIndex. In addition, it allows spatial filtering based on geometries (powered by shapely.STRtree).

Parameters:
indexxarray.indexes.PandasIndex

An Xarray (pandas) index built from an array-like of shapely.Geometry objects.

crspyproj.crs.CRS or any, optional

The coordinate reference system. Any value accepted by pyproj.crs.CRS.from_user_input().

Attributes:
crs

Returns the coordinate reference system of the index as a pyproj.crs.CRS object.

sindex

Returns the spatial index, i.e., a shapely.STRtree object.

Methods

concat(indexes, dim[, positions])

Create a new index by concatenating one or more indexes of the same type.

copy([deep])

Return a (deep) copy of this index.

create_variables([variables])

Maybe create new coordinate variables from this index.

equals(other)

Compare this index with another index of the same type.

from_variables(variables, *, options)

Create a new index object from one or more coordinate variables.

isel(indexers)

Maybe returns a new index from the current index itself indexed by positional indexers.

join(other[, how])

Return a new index from the combination of this index with another index of the same type.

reindex_like(other[, method, tolerance])

Query the index with another index of the same type.

rename(name_dict, dims_dict)

Maybe update the index with new coordinate and dimension names.

roll(shifts)

Roll this index by an offset along one or more dimensions.

sel(labels[, method, tolerance])

Query the index with arbitrary coordinate label indexers.

stack(variables, dim)

Create a new index by stacking coordinate variables into a single new dimension.

to_pandas_index()

Cast this xarray index to a pandas.Index object or raise a TypeError if this is not supported.

unstack()

Unstack a (multi-)index into multiple (single) indexes.

__init__(index, crs=None)#

Methods

__init__(index[, crs])

concat(indexes, dim[, positions])

Create a new index by concatenating one or more indexes of the same type.

copy([deep])

Return a (deep) copy of this index.

create_variables([variables])

Maybe create new coordinate variables from this index.

equals(other)

Compare this index with another index of the same type.

from_variables(variables, *, options)

Create a new index object from one or more coordinate variables.

isel(indexers)

Maybe returns a new index from the current index itself indexed by positional indexers.

join(other[, how])

Return a new index from the combination of this index with another index of the same type.

reindex_like(other[, method, tolerance])

Query the index with another index of the same type.

rename(name_dict, dims_dict)

Maybe update the index with new coordinate and dimension names.

roll(shifts)

Roll this index by an offset along one or more dimensions.

sel(labels[, method, tolerance])

Query the index with arbitrary coordinate label indexers.

stack(variables, dim)

Create a new index by stacking coordinate variables into a single new dimension.

to_pandas_index()

Cast this xarray index to a pandas.Index object or raise a TypeError if this is not supported.

unstack()

Unstack a (multi-)index into multiple (single) indexes.

Attributes

crs

Returns the coordinate reference system of the index as a pyproj.crs.CRS object.

sindex

Returns the spatial index, i.e., a shapely.STRtree object.