@echo off

set SAGA=.
set SAGA_MLB=%SAGA%\modules
PATH=PATH;%SAGA%;%SAGA_MLB%

if exist .\srtm.asc goto :SRTM
echo _____________________________________________
echo import SRTM-DEM from ESRI ASCII grid
saga_cmd.exe recreations_fractals 5 -GRID .\dem.sgrd -NX 400 -NY 400 -H 0.75

goto :GO

:SRTM
echo _____________________________________________
echo import SRTM-DEM from ESRI ASCII grid
saga_cmd.exe io_grid              1 -FILE .\srtm.asc -GRID .\srtm.sgrd

echo _____________________________________________
echo projection from geodetic to UTM zone 32

saga_cmd.exe pj_proj4             1 -SOURCE .\srtm.sgrd -OUT_GRID .\dem.sgrd -PROJ_TYPE 109 -utm_zone 32 -TARGET_TYPE 1 -GET_AUTOFIT_GRIDSIZE 90.0

:GO
echo _____________________________________________
echo create contour lines from DEM

saga_cmd.exe shapes_grid          5 -INPUT .\dem.sgrd -CONTOUR .\contour.shp -ZSTEP 25.0

echo _____________________________________________
echo do some terrain analysis

saga_cmd.exe ta_preprocessor      1 -DEM .\dem.sgrd -DEM_PREPROC .\dem.sgrd
saga_cmd.exe ta_lighting          0 -ELEVATION .\dem.sgrd -SHADE .\shade.sgrd -METHOD 0 -AZIMUTH -45 -DECLINATION 45
saga_cmd.exe ta_morphometry       0 -ELEVATION .\dem.sgrd -SLOPE .\slope.sgrd -ASPECT .\aspect.sgrd -HCURV .\hcurv.sgrd -VCURV .\vcurv.sgrd
saga_cmd.exe ta_hydrology         0 -ELEVATION .\dem.sgrd -CAREA .\carea.sgrd
saga_cmd.exe ta_hydrology        14 -SLOPE .\slope.sgrd -AREA .\carea.sgrd -WETNESS .\wetness.sgrd -STREAMPOW .\streampow.sgrd -LSFACTOR .\lsfactor.sgrd

echo _____________________________________________
echo perform cluster analysis

saga_cmd.exe grid_discretisation  1 -INPUT .\dem.sgrd;.\slope.sgrd;.\hcurv.sgrd;.\vcurv.sgrd -RESULT .\cluster.sgrd -STATISTICS .\cluster.txt -NORMALISE -NCLUSTER 10

pause
