experimental.to_dataarray_xvec

experimental.to_dataarray_xvec(res)

Convert a Res1D object to an xarray DataArray with an xvec GeometryIndex.

The DataArray will have dimensions (time, geometry). Note that the geometry index is not guaranteed to be unique: identical geometries may appear multiple times and will be preserved in the index. The DataArray also retains the original feature coordinates produced by the underlying conversion (quantity, group, chainage, name), so those coordinates are available alongside the geometry coordinate.

Parameters

Name Type Description Default
res Res1D The Res1D object. required

Returns

Name Type Description
xr.DataArray DataArray with dimensions (time, geometry) coordinate registered in the xindex.

Examples

>>> da = to_dataarray_xvec(res)
>>> da

Plot all node water levels at first time step:

>>> (da
    .where(
        (da.quantity == "WaterLevel") &
        (da.group == "Node")
    )
    .isel(time=0)
    .xvec.plot()
)

Get values within point radius:

>>> point = Point(-687763.099, -1056440.1).buffer(100)
>>> da.xvec.query("geometry", [point], predicate="intersects")