hydromt.model.components.MeshComponent.create_2d_from_region#

MeshComponent.create_2d_from_region(region: Dict[str, Any], *, res: float | None = None, crs: int | None = None, region_crs: int = 4326, grid_name: str = 'mesh2d', align: bool = True) UgridDataset[source]#

HYDROMT CORE METHOD: Create an 2D unstructured mesh or reads an existing 2D mesh according UGRID conventions.

Grids are read according to UGRID conventions. An 2D unstructured mesh will be created as 2D rectangular grid from a geometry (geom_filename) or bbox. If an existing 2D mesh is given, then no new mesh will be generated but an extent can be extracted using the bounds argument of region.

Note Only existing meshed with only 2D grid can be read.

Parameters:
  • region (dict) –

    Dictionary describing region of interest, bounds can be provided for type ‘mesh’. In case of ‘mesh’, if the file includes several grids, the specific 2D grid can be selected using the ‘grid_name’ argument. CRS for ‘bbox’ and ‘bounds’ should be 4326; e.g.:

    • {‘bbox’: [xmin, ymin, xmax, ymax]}

    • {‘geom’: ‘path/to/polygon_geometry’}

    • {‘mesh’: ‘path/to/2dmesh_file’}

    • {‘mesh’: ‘path/to/mesh_file’, ‘grid_name’: ‘mesh2d’, ‘bounds’: [xmin, ymin, xmax, ymax]}

  • res (float, optional) – Resolution used to generate 2D mesh [unit of the CRS], required if region is not based on ‘mesh’.

  • crs (int, optional) – Optional EPSG code of the model. If None using the one from region, and else 4326.

  • region_crs (int, optional) – EPSG code of the region geometry, by default None. Only applies if region is of kind ‘bbox’or if geom crs is not defined in the file itself.

  • align (bool, default True) – Align the mesh to the resolution. Required for ‘bbox’ and ‘geom’ region types.

  • grid_name (str, optional) – Name of the 2D grid in the mesh, by default ‘mesh2d’.

Returns:

mesh2d – Generated mesh2d.

Return type:

xu.UgridDataset