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 3 forks source link

Handle NaNs properly in `fillsinks` #20

Open wkearn opened 3 months ago

wkearn commented 3 months ago

When you give a DEM with NaNs to fillsinks, it will currently hang because the morphological reconstruction never converges, and the maximum iteration cutoff is handled incorrectly.

The MATLAB code handles NaNs by setting them to infinity in the marker image, doing the reconstruction, and then restoring them to NaNs after the reconstruction.

wkearn commented 3 months ago

21 handles the loop cutoff, so fillsinks will now eventually terminate if called with a DEM with NaNs.