1
|
/* using srtmv41 3x3 degree patch smoothed to srtmv41_smth
|
2
|
|
3
|
&describe srtmv41_smth
|
4
|
&sv cellsize %grd$dx% * 111000
|
5
|
dzdx = (srtmv41_smth(1,0) - srtmv41_smth(-1,0)) / (2 * %cellsize% * cos($$ymap / deg))
|
6
|
dzdy = (srtmv41_smth(0,-1) - srtmv41_smth(0,1)) / (2 * %cellsize%)
|
7
|
slope = sqrt(sqr(dzdx) + sqr(dzdy))
|
8
|
slopedeg = atan(slope) * deg
|
9
|
/* use scaling factor that is average of x and y scaling factors, 0.707 and 1 ~= 0.85
|
10
|
/* and 0.85 / 111000 ~ 0.0000107
|
11
|
arcslope = slope(srtmv41_smth, 0.0000107, degree)
|
12
|
hillshade = hillshade(srtmv41_smth, 300, 30, shade, 0.00001)
|
13
|
|
14
|
aspect1 = atan2(0 - dzdy, 0 - dzdx) * deg
|
15
|
aspect = con(aspect1 > 90, 450 - aspect1, 90 - aspect1)
|
16
|
kill aspect1
|
17
|
|
18
|
/*use elevation
|
19
|
flowdir = flowdirection(srtmv41_smth)
|
20
|
|
21
|
/*cell area to account for latitudinal area effects, smallest area near pole
|
22
|
setwindow srtmv41_smth
|
23
|
setcell srtmv41_smth
|
24
|
cellarea = sqr(%cellsize%) * cos($$ymap / deg)
|
25
|
flowacc = flowaccumulation(flowdir, cellarea)
|
26
|
|
27
|
/*account for sinks
|
28
|
/*change # defaulto z limit
|
29
|
/*caution fill is a command not function
|
30
|
/*fill srtmv41_smth srtmv41_fill sink # flowdir_fill
|
31
|
|
32
|
flowacc_fill = flowaccumulation(flowdir_fill, cellarea)
|
33
|
|
34
|
/*scatch_fill is specific catchment area in m
|
35
|
scatch_fill = flowacc_fill / sqrt(cellarea) + sqrt(cellarea) / 2
|
36
|
/*setting the min slope to 0.1
|
37
|
adjslope = tan(max(slopedeg, 0.1) / deg)
|
38
|
|
39
|
twi_fill = ln(scatch_fill / adjslope)
|