hydromt.gis.Dataset.vector.from_gdf#

static gis.Dataset.vector.from_gdf(gdf: GeoDataFrame, data_vars: Mapping[Any, Any] | DataArray | Dataset | None = None, coords: Mapping[Any, Any] | None = None, index_dim: str | None = None, keep_cols: bool = True, cols_as_data_vars: bool = False, merge_index: str = 'gdf') Dataset#

Create Dataset with geospatial coordinates.

Parameters:
  • gdf (geopandas GeoDataFrame) – Spatial coordinates. The index should match the df index and the geometry column may only contain Polygon, MultiPolygon, and Point geometries. Additional columns are also parsed to the xarray DataArray coordinates.

  • data_vars (dict-like, DataArray or Dataset) – A mapping from variable names to xarray.DataArray objects. See xarray.Dataset for all options. Additionally it accepts xarray.DataArray with name property and xarray.Dataset.

  • coords (sequence or dict of array_like, optional) – Coordinates (tick labels) to use for indexing along each dimension.

  • index_dim (str, optional) – Name of index dimension in data_vars

  • keep_cols (bool, optional) – If True, keep gdf columns as extra coordinates in dataset

  • cols_as_data_vars (bool, optional) – If True, parse gdf columns as data variables rather than coordinates.

  • merge_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 – Dataset with geospatial coordinates

Return type:

xarray.Dataset