4

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?

5

Fill Sinks (Wang and Liu) is a QGIS processing algorithm that calls an external (3rd party) tool SAGA.

The code to call SAGA is in SagaAlgorithm.py.

The source for the SAGA command is either:

  • How would I go about calling the SAGA command using SagaAlgorithm.py through an IDE? – Suspectful Aug 2 '18 at 18:54
  • @Suspectful, processing.run. If you have further questions,ask a new question. – user2856 Aug 2 '18 at 20:35
4

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.

  • And this is one of the things I love about WB GIS. It took me a lot of mucking around to figure out where the source for the QGIS/SAGA implementation was... With WB GIS you can access it from the program itself. – user2856 Jul 12 '18 at 0:08
1

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:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.