hydromt.model.components.SpatialDatasetsComponent#

class hydromt.model.components.SpatialDatasetsComponent(model: Model, *, region_component: str, filename: str = 'spatial_datasets/{name}.nc', region_filename: str = 'spatial_datasets/spatial_datasets_region.geojson')[source]#

A component to manage collection of geospatial xarray objects.

It contains a dictionary of xarray DataArray or Dataset objects. Compared to DatasetsComponent this component has a region property.

Initialize a SpatialDatasetsComponent.

Parameters:
  • model (Model) – HydroMT model instance

  • region_component (str) – The name of the region component to use as reference for this component’s region.

  • filename (str) – The path to use for reading and writing of component data by default. by default “spatial_datasets/{name}.nc” ie one file per xarray object in the data dictionary.

  • region_filename (str) – The path to use for writing the region data to a file. By default “spatial_datasets/spatial_datasets_region.geojson”.

__init__(model: Model, *, region_component: str, filename: str = 'spatial_datasets/{name}.nc', region_filename: str = 'spatial_datasets/spatial_datasets_region.geojson')[source]#

Initialize a SpatialDatasetsComponent.

Parameters:
  • model (Model) – HydroMT model instance

  • region_component (str) – The name of the region component to use as reference for this component’s region.

  • filename (str) – The path to use for reading and writing of component data by default. by default “spatial_datasets/{name}.nc” ie one file per xarray object in the data dictionary.

  • region_filename (str) – The path to use for writing the region data to a file. By default “spatial_datasets/spatial_datasets_region.geojson”.

Methods

__init__(model, *, region_component[, ...])

Initialize a SpatialDatasetsComponent.

add_raster_data_from_raster_reclass(...[, ...])

HYDROMT CORE METHOD: Add data variable(s) to datasets component by reclassifying the data in raster_filename based on reclass_table_filename.

add_raster_data_from_rasterdataset(...[, ...])

HYDROMT CORE METHOD: Add data variable(s) from raster_filename to datasets component.

read([filename, single_var_as_array])

Read model dataset files at <root>/<filename>.

set(data[, name, split_dataset])

Add data to the xarray component.

test_equal(other)

Test if two DatasetsComponents are equal.

write([filename, gdal_compliant, ...])

Write dictionary of xarray.Dataset and/or xarray.DataArray to netcdf files.

write_region(*[, filename, to_wgs84])

Write the model region to file.

Attributes

bounds

Return the total bounds of the model region.

crs

Provide access to the CRS of the model region.

data

Model data in the form of xarray objects.

data_catalog

Return the data catalog of the model this component is associated with.

model

Return the model object this component is associated with.

region

Provide access to the underlying GeoDataFrame data of the model region.

root

Return the root of the model this component is associated with.