Loading a river network¶
earthkit-hydro supports multiple river network formats, including PCRaster, CaMa-Flood, HydroSHEDS, MERIT-Hydro and GRIT.
Pre-computed river networks¶
Many commonly used river networks are available pre-computed. This is the recommended way to load a network:
import earthkit.hydro as ekh
# Load the EFAS version 5 river network
network = ekh.river_network.load("efas", "5")
For a full list of available networks, see the API reference earthkit.hydro.river_network.
Custom river networks¶
If a river network is not available via load, you can create one from a file in any supported format:
network = ekh.river_network.create(path, river_network_format, source)
This operation involves topologically sorting the network, which is computationally expensive for large grids. It is therefore recommended to export the result for re-use:
network.export("my_river_network.joblib")
In subsequent analyses, the pre-computed network can be loaded directly:
network = ekh.river_network.create("my_river_network.joblib", "precomputed")
See also¶
Loading/creating river networks — Tutorial walkthrough
River network concepts — How river networks are represented
earthkit.hydro.river_network — API reference