hydromt.model.components.MeshComponent#
- class hydromt.model.components.MeshComponent(model: Model, *, filename: str = 'mesh/mesh.nc', region_component: str | None = None, region_filename: str = 'mesh/mesh_region.geojson')[source]#
ModelComponent class for mesh components.
This class is used to manage unstructured mesh data in a model. The mesh component data stored in the
data
property is a xugrid.UgridDataset object.Initialize a MeshComponent.
- Parameters:
model (
Model
) – HydroMT model instancefilename (
str
) – The path to use for reading and writing of component data by default. by default “mesh/mesh.nc”.region_component (
str
, optional) – The name of the region component to use as reference for this component’s region. If None, the region will be set to the total bounds of the mesh. Note that the create method only works if the region_component is None. For add_data_from_* methods, the other region_component should be a reference to another mesh component for correct reprojection.region_filename (
str
) – The path to use for reading and writing of the region data by default. by default “mesh/mesh_region.geojson”.
- __init__(model: Model, *, filename: str = 'mesh/mesh.nc', region_component: str | None = None, region_filename: str = 'mesh/mesh_region.geojson')[source]#
Initialize a MeshComponent.
- Parameters:
model (
Model
) – HydroMT model instancefilename (
str
) – The path to use for reading and writing of component data by default. by default “mesh/mesh.nc”.region_component (
str
, optional) – The name of the region component to use as reference for this component’s region. If None, the region will be set to the total bounds of the mesh. Note that the create method only works if the region_component is None. For add_data_from_* methods, the other region_component should be a reference to another mesh component for correct reprojection.region_filename (
str
) – The path to use for reading and writing of the region data by default. by default “mesh/mesh_region.geojson”.
Methods
__init__
(model, *[, filename, ...])Initialize a MeshComponent.
add_2d_data_from_raster_reclass
(...[, ...])HYDROMT CORE METHOD: Add data variable(s) to 2D
grid_name
in mesh object by reclassifying the data inraster_filename
based onreclass_table_filename
.add_2d_data_from_rasterdataset
(...[, ...])HYDROMT CORE METHOD: Add data variable(s) from
raster_filename
to 2Dgrid_name
in mesh object.create_2d_from_region
(region, *[, res, crs, ...])HYDROMT CORE METHOD: Create an 2D unstructured mesh or reads an existing 2D mesh according UGRID conventions.
get_mesh
(grid_name[, include_data])Return a specific grid topology from mesh based on grid_name.
read
([filename, crs])Read model mesh data at <root>/<filename> and add to mesh property.
set
(data, *[, name, grid_name, overwrite_grid])Add data to mesh.
test_equal
(other)Test if two components are equal.
write
([filename, region_options, ...])Write model grid data to a netCDF file at <root>/<filename>.
write_region
(*[, filename, to_wgs84])Write the model region to file.
Attributes
Returns model mesh bounds.
Returns model mesh crs.
Model static mesh data.
Return the data catalog of the model this component is associated with.
Dictionnary of grid names and corresponding UgridDataset topology and data variables in mesh.
Returns dict of geometry of grids in mesh as a gpd.GeoDataFrame.
Dictionary of grid names and Ugrid topologies in mesh.
List of grid names in mesh.
Return the model object this component is associated with.
Provide access to the underlying GeoDataFrame data of the model region.
Return the root of the model this component is associated with.