[GRASS-user] How to find elevation drop for all cells in a basin

Anna Petrášová kratochanna at gmail.com
Tue Dec 15 11:29:14 PST 2020


On Tue, Dec 15, 2020 at 1:10 PM Ken Mankoff <mankoff at gmail.com> wrote:

>
> 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.
>
>
I admit I haven't read the entire email, but isn't r.stream.distance what
you need?

Anna


> Thanks,
>
>   -k.
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20201215/a9254404/attachment.html>


More information about the grass-user mailing list