forked from awickert/GRASS-fluvial-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGSFLOWgrid.sh
60 lines (43 loc) · 1.71 KB
/
GSFLOWgrid.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# "value" is the cat for the
r.stream.basins direction=draindir stream_rast=streams basins=basins --o
r.to.vect in=basins out=basins type=area --o
g.region
v.mkgrid grid=50,50 map=grid --o
# basins
v.overlay ainput=basins binput=grid output=tmp op=and --o
# clean up with some v.db.renamecolumn commands
# streams
v.extract in=streams out=tmp2 type=line
v.overlay ainput=tmp2 atype=line binput=boxtmp output=tmp3 op=and --o
# And then sort from top to bottom by:
# (1) finding segments with proper a_cat
# (2) finding which one ends with x_1, y_1
# (3) following up downriver until reaching x_2, y_2
# (4) while doing (3), make sure that all reaches are organized
# upstream to downstream
# (5) Once all reaches are ordered, give them numbers. This may require
# adding a column as step (1.5).
# UPDATE DECEMBER 1ST
# Basins 3x resolution
g.region rast=topo -p
g.region -p nsres=92.44186047 ewres=92.87925695999999
# Actually, if it isn't going to be perfect -- just 90x90
# Or no -- 200
g.region -pas res=200
r.mapcalc "topogrid = topo" --o # topogrid is output topo on output grid
# Now make grid
v.mkgrid map=grid --o
# And output
r.out.ascii in=topogrid out=topo.asc
r.out.ascii in=basin out=basinmask.asc null_value=0 --o
# Now overlay basins
# Automatically comes with b_row and b_col from the grid
v.overlay ainput=basins binput=grid output=tmp op=and --o
# And rename column values to everything needed by GSFLOW
## THIS DONE IN OTHER PROGRAMS IN GRASS-fluvial-profiler directory (here)
# streams
# repeat if needed
v.extract in=streams out=tmp2 type=line --o
v.overlay ainput=tmp2 atype=line binput=grid output=tmp3 op=and --o
# (1) Add all required segments
# (1) get the start and end segments of the reaches