<div dir="ltr">Hi Ken,<div><br></div><div>What exactly do you mean by elevation drop (at each cell)? I can only guess…</div><div><br></div><div>Tom</div></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-width:1px;border-left-style:solid;border-left-color: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>
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><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr">Thomas E Adams, III<div>1724 Sage Lane</div><div>Blacksburg, VA 24060</div><div><a href="mailto:tea3rd@gmail.com" target="_blank">tea3rd@gmail.com</a> (personal)</div><div><a href="mailto:tea@terrapredictions.org" target="_blank">tea@terrapredictions.org</a> (work)<br></div><div><br></div><div>1 (513) 739-9512 (cell)</div><div><br></div></div></div></div></div></div>