Skip to main content

Posts

Showing posts from July, 2024

Use NetworkX for GEOframe topology

A basin network can be seen as a graph, specifically as a directed acyclic tree . In GEOframe , the topology of the basins, which describes the direction of the flow and the interconnections of the basins, is usually saved in a text file with two columns: the first column represents the origin basin , and the second column represents the target basin . The 0 is used to mark the outlet of the network. For example: 8 7 7 4 6 5 5 4 4 3 3 2 2 1 1 0 The 0 mark the outlet. In my work, I've encountered the need to manipulate basin networks so verifying the topological correctness of these new graphs is crucial. To accomplish this task, I chose the NetworkX Python library. This library facilitates a variety of tasks—such as cutting the network, iterating through the network, and comparing two or more networks within the same watershed—thanks to its class structure, specifically the Graph class. As a result, I've developed some functions for basic operations on the network and shar