hydromt.GridModel.setup_grid#
- GridModel.setup_grid(region: dict, res: float | None = None, crs: int = None, rotated: bool = False, hydrography_fn: str | None = None, basin_index_fn: str | None = None, add_mask: bool = True, align: bool = True, dec_origin: int = 0, dec_rotation: int = 3) DataArray [source]#
HYDROMT CORE METHOD: 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.
Adds/Updates model layers (if add_mask): * mask grid mask: add grid mask to grid object
- 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].
res (
float
) – Resolution used to generate 2D grid [unit of the CRS], required if region is not based on ‘grid’.crs (
EPSG code
,int
,str optional
) – EPSG code of the model or “utm” to let hydromt find the closest projectedrotated (
bool
, optional) – 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
) –- 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_fn (
str
) – 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
, optional) – Add mask variable to grid object, by default True.align (
bool
, optional) – 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 3
- Returns:
grid – Generated grid mask.
- Return type:
xr.DataArray