xarray.DataArray.xvec.is_geom_variable#

DataArray.xvec.is_geom_variable(name, has_index=True)#

Check if coordinate variable is composed of shapely.Geometry.

Can return all such variables or only those using GeometryIndex.

Parameters:
namecoordinate variable name
has_indexbool, optional

control if all variables are returned (False) or only those that have xvec.GeometryIndex assigned (True). By default False

Returns:
bool

Examples

>>> ds = (
...     xr.Dataset(
...         coords={
...             "geom": np.array([shapely.Point(1, 2), shapely.Point(3, 4)]),
...             "geom2": np.array([shapely.Point(1, 2), shapely.Point(3, 4)]),
...             "foo": np.array([1, 2]),
...         }
...     )
...     .xvec.set_geom_indexes("geom", crs=26915)
... )
>>> ds
<xarray.Dataset>
Dimensions:  (geom: 2, geom2: 2, foo: 2)
Coordinates:
  * geom     (geom) object POINT (1 2) POINT (3 4)
  * geom2    (geom2) object POINT (1 2) POINT (3 4)
  * foo      (foo) int64 1 2
Data variables:
    *empty*
Indexes:
    geom     GeometryIndex (crs=EPSG:26915)
>>> ds.xvec.is_geom_variable("geom")
True
>>> ds.xvec.is_geom_variable("foo")
False
>>> ds.xvec.is_geom_variable("geom2")
False
>>> ds.xvec.is_geom_variable("geom2", has_index=False)
True