Specifically, I have outlets and basins. I can find the (x,y) location of the
outlet for every cell in each basin using the following code. Note that I'm
doing this for all cells in the basin, not just stream cells. The
r.stream.order does provide elev_drop. I'd like this for non-stream cells too,
for each basin.
Assuming that I have a outlets with unique IDs, I can create basins for each
outlet with:
# dir comes from r.stream.extract
r.stream.basins -m direction=dir points=outlets basins=basins
g.copy basins,cat_x
g.copy basins,cat_y
I can then export the x and y location of each outlet to a file:
r.out.xyz input=outlets | awk -F'|' '{print $3, $1}' > ./tmp/outlets_x
r.out.xyz input=outlets | awk -F'|' '{print $3, $2}' > ./tmp/outlets_y
I can then copy my basins (same categories as outlets) and change the category
to x and y.
r.category map=cat_x rules=./tmp/outlets_x separator=space
r.category map=cat_y rules=./tmp/outlets_y separator=space
Note: There is probably a way to combine the above r.out.xyz and r.category
commands so that I don't need to use a temporary disk file.
Finally, convert x and y from category to value
r.mapcalc "outlet_x = @cat_x"
r.mapcalc "outlet_y = @cat_y"
I can then use outlet_x and outlet_y, for example in r.mapcalc to find the
direct distance between each inland cell and the outlet:
r.mapcalc "dist = (outlet_x^2 + outlet_y^2)^(0.5)"
Rather than finding the distance from each inland cell to its outlet, I'd like
to find the elevation change from each inland cell to its outlet. Is this
possible to do efficiently in the Bash interface to GRASS? I can do it with
some loops in Python but prefer to stay in Bash if possible.
Thanks,
-k.
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user