hydromt.DataArray.vector.from_gdf#

static DataArray.vector.from_gdf(gdf: GeoDataFrame, data: Any, coords: Optional[dict] = None, dims: Optional[tuple] = None, name: Optional[str] = None, index_dim: Optional[str] = None, keep_cols: bool = True) DataArray#

Parse GeoDataFrame object with point geometries to DataArray with geospatial attributes and merge 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 an numpy.ndarray, ndarray like, or castable to an ndarray. 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 or dict of array_like, optional) – Coordinates (tick labels) to use for indexing along each dimension.

  • dims (hashable or sequence of hashable, 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'].

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

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

Returns:

da – DataArray with geospatial coordinates

Return type:

xarray.DataArray