Are there any open source tools to detect and fill sinks on a DEM?

GRASS has r.fill.dir and better yet, r.terraflow, which is one of the few hydrology tools to work on massive rasters. There's also TauDem, which includes PitRemove for filling.


SAGA has several fill methods

http://www.saga-gis.org/saga_modules_doc/ta_preprocessor/index.html

Flat Detection
Sink Drainage Route Detection
Sink Removal
Fill Sinks (Planchon/Darboux, 2001)
Fill Sinks (Wang & Liu)
Fill Sinks XXL (Wang & Liu)


This is actually an area of active research for me.

You can use the Priority-Flood algorithm as described by this journal article, which is also available on arXiv. This allows you to fill depressions in O(n log n) time for floating-point data and O(n) time for integer data. Source code is available here.

The foregoing algorithm is serial and works well up to a hundred million cells or so. Sometimes, though, your datasets are larger.

This article, also available on arXiv, describes an algorithm with excellent scaling suitable for datasets of up to a trillion or more cells. Source is available here.

All of the foregoing is now included in RichDEM's Python wrapper. Documentation, with examples and pretty pictures, is available here.

Depression-filling as performed on Beauford watershed

(Disclaimer: I wrote the articles and code mentioned above.)