rameau.core.Tree.from_csv
- static Tree.from_csv(path, watersheds)[source]
Import connections between upstream and downstream watersheds from a CSV file. The CSV file must contain two columns of integer values, with a header line at the beginning of the file.
- Parameters:
path (
str) – Path to CSV file.watersheds (
listordict) –Watershedfor this watershed connection tree. If provided as a list, ids of each watershed are deduced from their positions in the list, starting from 1. If provided as a dictionary, keys correspond to the ids of the watersheds and values either toWatershedobject ordict. Keys needs to be consistent with theconnectionkeyword.
- Returns:
Examples
The content of an example of connection tree CSV file for three watersheds is shown below:
Watershed Downstream 1 3 2 3 3 0
Assuming this content is written in the
data/connection.csvfile, building a tree is done with:>>> wds = [rm.Watershed() for i in range(3)] >>> t = rm.Tree.from_csv(path="data/connection.csv", watersheds=wds) >>> for w in t.watersheds: ... print(f"Watershed {w.id}: {w.strahler_order}") Watershed 1: 1 Watershed 2: 1 Watershed 3: 2