Clipping a model#

The clip method allows to clip a subregion from an existing model, including all static maps, static geometries and forcing data.

Steps in brief:

  1. You have an existing model schematization ready

  2. Define your model subregion, see the overview of region options.

  3. Clip your model using the CLI or Python interface

Note

This method is not yet implemented for all plugins. Please check the documentation of the respective plugin for more information on whether the clip method is available.

From CLI#

Example usage

The hydromt clip command line interface (CLI) method can be run from the command line after the right conda environment is activated.

The following example clips a subbasin region (based on its outflow location) from an existing Wflow model at /path/to/model_root and saves the output to /path/to/model_destination. The subbasin is defined based on an outflow location snapped to a stream order 4 river which is based on a map called wflow_streamorder of the Wflow model.

hydromt clip wflow /path/to/model_root /path/to/model_destination "{'subbasin': [-7.24, 62.09], 'wflow_streamorder': 4}"

Overview of options

To check all options do:

hydromt clip --help
Usage: main clip [OPTIONS] MODEL MODEL_ROOT MODEL_DESTINATION REGION

  Create a new model based on clipped region of an existing model.

  If the existing model contains forcing, they will also be clipped to the new
  model.

  Example usage: --------------

  Example usage to clip a wflow model for a subbasin derived from point
  coordinates snapped to cells with upstream area >= 50 km2 hydromt clip wflow
  /path/to/model_root /path/to/model_destination "{'subbasin': [-7.24, 62.09],
  'wflow_uparea': 50}"

  Example usage basin based on ID from model_root basins map hydromt clip wflow
  /path/to/model_root /path/to/model_destination "{'basin': 1}"

  Example usage basins whose outlets are inside a geometry hydromt clip wflow
  /path/to/model_root /path/to/model_destination "{'outlet':
  'geometry.geojson'}"

  All available option in the clip_grid function help.

Options:
  -q, --quiet    Decrease verbosity.
  -v, --verbose  Increase verbosity.
  --help         Show this message and exit.

From Python#

Note

A general clip method for the model class is currently not yet available and its signature might change in the future.

Example usage

from hydromt_wflow import WflowModel
mod = WflowModel(r'/path/to/model_root', mode='r')  # initialize model with default logger in read mode
mod.clip_staticmaps(region={'subbasin': [-7.24, 62.09], 'wflow_streamorder': 4})
mod.clip_forcing()
mod.set_root(r'path/to/model_destination')  # change root to output directory
mod.write()