Skip to content

Instantly share code, notes, and snippets.

@schoeller
Last active October 12, 2018 19:13
Show Gist options
  • Save schoeller/44f0d8de52efd38bbc2953db12e44e7a to your computer and use it in GitHub Desktop.
Save schoeller/44f0d8de52efd38bbc2953db12e44e7a to your computer and use it in GitHub Desktop.
Automatic DEM treatment with TauDEM
#!/usr/sh
# works with Taudem 5.0.6
# Pit fill
mpiexec -n 8 pitremove -z dtm.tif -fel dtmfel.tif
# Flow directions
mpiexec -n 8 d8flowdir -p dtmp.tif -sd8 dtmsd8.tif -fel dtmfel.tif
mpiexec -n 8 dinfflowdir -ang dtmang.tif -slp dtmslp.tif -fel dtmfel.tif
# Contributing area
mpiexec -n 8 aread8 -p dtmp.tif -ad8 dtmad8.tif
mpiexec -n 8 areadinf -ang dtmang.tif -sca dtmsca.tif
mpiexec -n 8 aread8 -p dtmp.tif -o outlet.shp -ad8 dtmad8o.tif
# Gridnet
mpiexec -n 8 gridnet -p dtmp.tif -plen dtmplen.tif -tlen dtmtlen.tif -gord dtmgord.tif
# PeukerDouglas
mpiexec -n 8 peukerdouglas -fel dtmfel.tif -ss dtmss.tif
# PeukerDouglas stream delineation
mpiexec -n 8 aread8 -p dtmp.tif -o outlet.shp -ad8 dtmssa.tif -wg dtmss.tif
mpiexec -n 8 dropanalysis -p dtmp.tif -fel dtmfel.tif -ad8 dtmad8.tif -ssa dtmssa.tif -drp dtmdrp.txt -o outlet.shp -par 5 500 10 0
mpiexec -n 8 threshold -ssa dtmssa.tif -src dtmsrc.tif -thresh 300
# Stream Network
mpiexec -n 8 streamnet -fel dtmfel.tif -p dtmp.tif -ad8 dtmad8.tif -src dtmsrc.tif -ord dtmord3.tif -tree dtmtree.dat -coord dtmcoord.dat -net dtmnet.shp -w dtmw.tif -o outlet.shp
# Convert watersheds to shp
# gdal_polygonize.py dtmw.tif -f "ESRI Shapefile" . dtmw
saga_cmd io_gdal 0 -GRIDS dtmw -FILES dtmw.tif
saga_cmd shapes_grid 6 -GRID:dtmw.sgrd -POLYGONS dtmw -SPLIT:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment