hydromt.model.processes.grid.create_grid_from_region#
- hydromt.model.processes.grid.create_grid_from_region(region: Dict[str, Any], *, data_catalog: DataCatalog | None = None, res: int | float | None = None, crs: int | None = None, region_crs: int = 4326, rotated: bool = False, hydrography_path: str | None = None, basin_index_path: str | None = None, add_mask: bool = True, align: bool = True, dec_origin: int = 0, dec_rotation: int = 3) DataArray [source]#
Create a 2D regular grid or reads an existing grid.
A 2D regular grid will be created from a geometry (geom_fn) or bbox. If an existing grid is given, then no new grid will be generated.
- Parameters:
region (
dict
) –Dictionary describing region of interest, e.g.: * {‘bbox’: [xmin, ymin, xmax, ymax]} * {‘geom’: ‘path/to/polygon_geometry’} * {‘grid’: ‘path/to/grid_file’} * {‘basin’: [x, y]}
Region must be of kind [grid, bbox, geom, basin, subbasin, interbasin].
data_catalog (
DataCatalog
, optional) – If the data_catalog is None, a new DataCatalog will be created, by default None.res (
float
orint
, optional) – Resolution used to generate 2D grid [unit of the CRS], required if region is not based on ‘grid’.crs (
int
, optional) – EPSG code of the grid to create.region_crs (
int
, optional) – EPSG code of the region geometry, by default 4326. Only applies if region is of kind ‘bbox’ or if geom crs is not defined in the file itself.rotated (
bool
) – if True, a minimum rotated rectangular grid is fitted around the region, by default False. Only applies if region is of kind ‘bbox’, ‘geom’hydrography_fn (
str
, optional) –- Name of data source for hydrography data. Required if region is of kind
’basin’, ‘subbasin’ or ‘interbasin’.
- Required variables: [‘flwdir’] and any other ‘snapping’ variable required
to define the region.
- Optional variables: [‘basins’] if the region is based on a
(sub)(inter)basins without a ‘bounds’ argument.
basin_index_path (
str
, optional) – Name of data source with basin (bounding box) geometries associated with the ‘basins’ layer of hydrography_fn. Only required if the region is based on a (sub)(inter)basins without a ‘bounds’ argument.add_mask (
bool
) – Add mask variable to grid object, by default True.align (
bool
) – If True (default), align target transform to resolution.dec_origin (
int
, optional) – number of decimals to round the origin coordinates, by default 0dec_rotation (
int
, optional) – number of decimals to round the rotation angle, by default 3logger (
Logger
) – Logger object, by default a module level logger is used.
- Returns:
grid – Generated grid mask.
- Return type:
xr.DataArray