hydromt.gis.DataArray.vector.from_gdf#
- static gis.DataArray.vector.from_gdf(gdf: GeoDataFrame, data: Any, coords: dict | None = None, dims: tuple | None = None, name: str | None = None, index_dim: str | None = None, keep_cols: bool = True, merge_index: str = 'gdf') DataArray #
Parse GeoDataFrame object with point geometries to DataArray.
DataArray will have geospatial attributes and be merged with array_like data.
- Parameters:
gdf (
geopandas GeoDataFrame
) – Spatial coordinates. The index should match the array_like index_dim and the geometry column may only contain Point geometries.data (
array_like
) – Values for this array. Must be annumpy.ndarray
, ndarray like, or castable to anndarray
. If a self-described xarray or pandas object, attempts are made to use this array’s metadata to fill in other unspecified arguments. A view of the array’s data is used instead of a copy if possible.coords (
sequence
ordict
ofarray_like
, optional) – Coordinates (tick labels) to use for indexing along each dimension.dims (
hashable
orsequence
ofhashable
, optional) – Name(s) of the data dimension(s). Must be either a hashable (only for 1D data) or a sequence of hashables with length equal to the number of dimensions. If this argument is omitted, dimension names default to['dim_0', ... 'dim_n']
.name (
str
, optional) – The name of the data set for metadata purposes.index_dim (
str
, optional) – Name of index dimension of datakeep_cols (
bool
, optional) – If True, keep gdf columns as extra coordinates in datasetmerge_index (
{'gdf', 'inner'}
, default'gdf'
) –Type of merge to be performed between gdf and data.
gdf: use only keys from gdf index. Missing values will be filled with NaNs
inner: use intersection of gdf and data index.
- Returns:
da – DataArray with geospatial coordinates
- Return type: