<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 15, 2020 at 1:10 PM Ken Mankoff <<a href="mailto:mankoff@gmail.com">mankoff@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
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.<br>
<br>
Assuming that I have a outlets with unique IDs, I can create basins for each outlet with:<br>
<br>
# dir comes from r.stream.extract<br>
r.stream.basins -m direction=dir points=outlets basins=basins<br>
<br>
g.copy basins,cat_x<br>
g.copy basins,cat_y<br>
<br>
I can then export the x and y location of each outlet to a file:<br>
<br>
<a href="http://r.out.xyz" rel="noreferrer" target="_blank">r.out.xyz</a> input=outlets | awk -F'|' '{print $3, $1}' > ./tmp/outlets_x<br>
<a href="http://r.out.xyz" rel="noreferrer" target="_blank">r.out.xyz</a> input=outlets | awk -F'|' '{print $3, $2}' > ./tmp/outlets_y<br>
<br>
I can then copy my basins (same categories as outlets) and change the category to x and y.<br>
<br>
r.category map=cat_x rules=./tmp/outlets_x separator=space<br>
r.category map=cat_y rules=./tmp/outlets_y separator=space<br>
<br>
Note: There is probably a way to combine the above <a href="http://r.out.xyz" rel="noreferrer" target="_blank">r.out.xyz</a> and r.category commands so that I don't need to use a temporary disk file.<br>
<br>
Finally, convert x and y from category to value<br>
<br>
r.mapcalc "outlet_x = @cat_x"<br>
r.mapcalc "outlet_y = @cat_y"<br>
<br>
<br>
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:<br>
<br>
r.mapcalc "dist = (outlet_x^2 + outlet_y^2)^(0.5)"<br>
<br>
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.<br>
<br></blockquote><div><br></div><div>I admit I haven't read the entire email, but isn't r.stream.distance what you need?</div><div><br></div><div>Anna</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thanks,<br>
<br>
-k.<br>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
</blockquote></div></div>