I would like to use the source code of "fill sinks (wang and liu)".
I checked through QGIS3 folders, but could not find much related to it.
Anyone know where the code could be?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
The Wang and Liu algorithm is also implemented in Whitebox GIS. You can find it listed under Hydrological Tools\DEM Pre-processing\Fill Depressions.
The source code can be very easily accessed using Whitebox's 'View Code' button on the tool. You can also navigate to the text file yourself. Or you can view it online. The code is written in Groovy, a java-based scripting language.
In addition to the Groovy-based implementation that Chris mentioned (a Whitebox GAT plugin), there is also a newer and more efficient Rust-based open-source implementation of the Wang and Lui depression filling method available in
WhiteboxTools. The source code for this tool can be found in the
WhiteboxTools Github repository. Importantly,
WhiteboxTools can be run independent of
Whitebox GAT (i.e. the Whitebox GIS user interface) and can be scripted using Python (See here for details).
from WBT.whitebox_tools import WhiteboxTools wbt = WhiteboxTools() dem = "/path/to/data/DEM.tif" output = "/path/to/data/filled_DEM.tif" wbt.fill_depressions(dem, output)
Additionally, this Rust-based depression filling tool is available from the Whitebox for Processing QGIS plugin: