TopoToolbox / libtopotoolbox

A C library for the analysis of digital elevation models.
https://topotoolbox.github.io/libtopotoolbox/
GNU General Public License v3.0
0 stars 5 forks source link

Discrepancies in flow routing between libtopotoolbox and TopoToolbox v2 #122

Open wkearn opened 1 week ago

wkearn commented 1 week ago

I noted in #72

There are differences between the two on flat regions that have to do with how the auxiliary topography is treated. TT2 itself computes different flow directions over flats with its MEX implementation and the default MATLAB implementation. The flow directions of the libtopotoolbox implementation seem more similar to the MATLAB implementation than to the MEX version. There is an unused function in src/flow_routing.c, compute_flowdirection_TT2, which attempts to more directly copy the MEX implementation. However, using compute_flowdirection_TT2 still matches the MATLAB implementation better than it matches the MEX implementation. I am open to exploring these discrepancies more, but I would like to have something that we can start building from.

The discrepancies I noticed when testing #72 seemed quite minor and limited to the flats, but these differences get amplified when computing the drainage basins from the flow routing information using #121.

Here are two maps of drainage basins on the Big Tujunga DEM included with TopoToolbox v2. The left one is computed with

DEM = GRIDobj("DEMdata/srtm_bigtujunga30m_utm11.tif");
FD = FLOWobj(DEM);
L = drainagebasins(FD);

while the right one is computed using libtopotoolbox's flow routing.

BigTujunga_Basins

It may be hard to tell, but among other things, there are twice as many basins in the libtopotoolbox version than in the TopoToolbox v2 version.

Most or maybe all of those extra basins are on the boundary, which makes me think that in addition to having problems routing over flats, we might also not be identifying outlets on the boundary of the DEM correctly. I didn't notice those earlier because I was primarily looking at maps of flow accumulation, and these small basins have very little flow accumulation.

I would like to figure out what is going on here before merging #121.

wkearn commented 1 week ago

Maybe this is a better figure. Top is TopoToolbox v2 and bottom is libtopotoolbox.

BigTujunga_Basins