Created
June 25, 2012 22:06
-
-
Save mlt/2991670 to your computer and use it in GitHub Desktop.
Alternative approach for PIHM GIS watershed delineation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set OSGEO4W_ROOT=C:\OSGeo4W | |
set GISBASE=%OSGEO4W_ROOT%\apps\grass\grass-6.4.2 | |
rem set GISBASE=%OSGEO4W_ROOT%\apps\grass\grass-7.0.svn | |
rem set GRASS_SH=%OSGEO4W_ROOT%\apps\msys\bin\sh.exe | |
SET PATH=%GISBASE%\bin;%GISBASE%\lib;%OSGEO4W_ROOT%\bin;%OSGEO4W_ROOT%\apps\msys\bin;%PATH% | |
SET GISRC=.grassrc | |
md grassdata\default\PERMANENT | |
SET DIR=%~dp0 | |
echo GISDBASE: %~dp0grassdata > .grassrc | |
echo LOCATION_NAME: default >> .grassrc | |
echo MAPSET: PERMANENT >> .grassrc | |
SET WIND=grassdata\default\PERMANENT/WIND | |
echo proj: 0 > %WIND% | |
echo zone: 0 >> %WIND% | |
echo north: 1 >> %WIND% | |
echo south: 0 >> %WIND% | |
echo east: 1 >> %WIND% | |
echo west: 0 >> %WIND% | |
echo cols: 1 >> %WIND% | |
echo rows: 1 >> %WIND% | |
echo e-w resol: 1 >> %WIND% | |
echo n-s resol: 1 >> %WIND% | |
echo top: 1 >> %WIND% | |
echo bottom: 0 >> %WIND% | |
echo cols3: 1 >> %WIND% | |
echo rows3: 1 >> %WIND% | |
echo depths: 1 >> %WIND% | |
echo e-w resol3: 1 >> %WIND% | |
echo n-s resol3: 1 >> %WIND% | |
echo t-b resol: 1 >> %WIND% | |
cp grassdata\default\PERMANENT\WIND grassdata\default\PERMANENT\DEFAULT_WIND | |
rem 6.4.2 | |
r.in.gdal -e input=RasterProcessing\fill.asc output=fill location=rst | |
g.gisenv set=LOCATION_NAME=rst | |
r.fill.dir input=dem elevation=fill direction=fdir areas=sinks | |
rem or instead of r.fill.dir | |
rem rem r.terraflow elevation=dem filled=fill direction=fdir swatershed=sinks accumulation=fac tci=tci --overwrite | |
r.watershed elev=fill accumulation=fac drain=fdir basin=catch stream=str thresh=10000 --overwrite | |
r.water.outlet drainage=fdir basin=wshed easting=507506.7953 northing=4928770.033 --overwrite | |
r.to.vect input=wshed output=wshed feature=area --overwrite | |
v.generalize input=wshed output=wshed_simp method=douglas threshold=100 | |
v.type input=wshed_simp output=wcont type=boundary,line --overwrite | |
rem # the stream raster usually requires thinning | |
r.thin in=str out=str_thin | |
r.to.vect in=str_thin out=streams feature=line | |
v.overlay ainput=streams atype=line binput=wshed_simp output=streams_wshed operator=and --overwrite | |
v.generalize input=streams_wshed output=streams_simp method=douglas threshold=100 --overwrite | |
rem won't work v.overlay ainput=streams_wshed atype=line binput=wcont output=merged --overwrite | |
v.patch input=streams_simp,wcont output=merged --overwrite | |
rem no need v.type input=merged output=merged_line type=boundary,line --overwrite | |
v.split input=merged output=merged_single vertices=2 | |
v.out.ogr input=merged_single type=line dsn=. olayer=merged --overwrite | |
rem g.proj -c location=rst | |
rem r.in.gdal -e input="C:\Documents and Settings\tito0003\My Documents\work\hsB\bc.tif" output=dem location=rst | |
rem r.watershed -f elev=dem accumulation=fac drain=fdir basin=catch stream=str thresh=10000 --overwrite | |
rem r.terraflow elev=dem filled=fil direction=fdir swatershed=catch accumulation=fac tci=tci --overwrite | |
rem r.basins.fill c_map=str result=basins | |
rem r.to.vect input=wshed output=wshed type=line --overwrite | |
rem # Use v.clean to remove tiny areas (that were a string of single cells in the raster) | |
rem v.clean wshed out=wshed_final tool=rmarea thresh=150 | |
rem r.stream.order stream=str dir=fdir strahler=strahler shreve=shreeve horton=horton hack=hack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment