xarray.Dataset.xvec.geom_coords_indexed

xarray.Dataset.xvec.geom_coords_indexed#

Dataset.xvec.geom_coords_indexed#

Returns a dictionary of xarray.DataArray objects corresponding to coordinate variables using GeometryIndex.

Examples

>>> ds = (
...     xr.Dataset(
...         coords={
...             "geom": np.array([shapely.Point(1, 2), shapely.Point(3, 4)]),
...             "geom_z": np.array(
...                 [shapely.Point(10, 20, 30), shapely.Point(30, 40, 50)]
...             ),
...             "geom_no_index": np.array(
...                 [shapely.Point(1, 2), shapely.Point(3, 4)]
...             ),
...         }
...     )
...     .xvec.set_geom_indexes(["geom", "geom_z"], crs=26915)
... )
>>> ds
<xarray.Dataset>
Dimensions:        (geom: 2, geom_z: 2, geom_no_index: 2)
Coordinates:
  * geom           (geom) object POINT (1 2) POINT (3 4)
  * geom_z         (geom_z) object POINT Z (10 20 30) POINT Z (30 40 50)
  * geom_no_index  (geom_no_index) object POINT (1 2) POINT (3 4)
Data variables:
    *empty*
Indexes:
    geom           GeometryIndex (crs=EPSG:26915)
    geom_z         GeometryIndex (crs=EPSG:26915)
>>> ds.xvec.geom_coords_indexed
Coordinates:
  * geom     (geom) object POINT (1 2) POINT (3 4)
  * geom_z   (geom_z) object POINT Z (10 20 30) POINT Z (30 40 50)