<div dir="ltr">Hi Michael,<div><br></div><div>I have not read the entire thread, but maybe follwowing might work</div><div>if you want to extract this upstream-downstream watercourse in raster format:</div><div><br></div><div>1) Use r.cost with your outlet as starting point and your cell resolution as</div><div>cost surface. So the output is a pseudo-elevation</div><div>map with increasing values in upstream direction</div><div><br></div><div>2) use r.drain to extract the main course in downstream direction based on a</div><div>defined upstream end and the pseudo-elevation map created by r.cost.</div><div><br></div><div>3) Than you can use r.to.vect to convert your raster cells to vectors and </div><div>extract your distance per point (cummulative cost) and your elevation.</div><div><br></div><div>Maybe this might help in on or the other way.</div><div><br></div><div>best,</div><div>Johannes</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 1, 2014 at 7:21 PM, Michael Barton <span dir="ltr"><<a href="mailto:Michael.Barton@asu.edu" target="_blank">Michael.Barton@asu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">v.build.polylines is indeed part of what is needed. But it is not enough to be able to use v.to.points in the data I have—and this is not a weirdly meandering stream, just a Mediterranean barranco.<br>
<br>
A major part of the problem is in the raster to vector conversion. I’ve been using r.to.vect. But it breaks the resulting line into multiple segments and assigns different cat numbers to the segments. If the segments all connect cleanly, v.build.polylines may combine the segments. But I’ve tried using cat=first and it continues to assign multiple cats to the segments. To get a single line, what I have to do currently is:<br>
<br>
v.clean<br>
v.build.polylines with cats=no<br>
v.category with option=del ## may not be necessary but I’ve had enough inconsistent results to want to make sure on this<br>
v.category with option=add cat=1 step=0 ## this gets me a vector with cat=1 for all parts.<br>
<br>
repeat the above a 2nd time<br>
<br>
This gives a sufficiently clean single-object line with a single cat number that I can run v.to.points on.<br>
<br>
Maybe r.stream.order does a cleaner job in raster to vector conversion. It’s worth a try. Unfortunately, I can’t use the stream order info to extract a stream since I want the stream from its headwaters (stream order = 1) to its outlet (stream order > 1).<br>
<br>
Ideally, there would be a module where I could enter the coordinates of the upstream end of a stream, it would extract the entire watercourse as a single object to its downstream end, edge of map, or a defined outlet stop point. Then I could run v.to.points and v.what.rast to get profile data. OR in a a stream profile module, it would run these for me. I could do it in Python if I could extract a clean vector (one object, one cat, no loops or self-crossing) of a single stream from a stream network created with r.watershed or r.stream.extract. AFAICT, there is nothing available in GRASS that can do this. Kind of surprising.<br>
<span class="HOEnZb"><font color="#888888"><br>
Michael<br>
</font></span><span class="im HOEnZb"><br>
<br>
____________________<br>
C. Michael Barton<br>
Director, Center for Social Dynamics & Complexity<br>
Professor of Anthropology, School of Human Evolution & Social Change<br>
Head, Graduate Faculty in Complex Adaptive Systems Science<br>
Arizona State University<br>
<br>
voice: 480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)<br>
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)<br>
www: <a href="http://www.public.asu.edu/~cmbarton" target="_blank">http://www.public.asu.edu/~cmbarton</a>, <a href="http://csdc.asu.edu" target="_blank">http://csdc.asu.edu</a><br>
<br>
<br>
<br>
</span><div class="HOEnZb"><div class="h5">On Dec 1, 2014, at 9:31 AM, Moritz Lennert <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>
<br>
> On 30/11/14 06:28, Michael Barton wrote:<br>
>><br>
>> ____________________<br>
>> C. Michael Barton<br>
>> Director, Center for Social Dynamics & Complexity<br>
>> Professor of Anthropology, School of Human Evolution & Social Change<br>
>> Head, Graduate Faculty in Complex Adaptive Systems Science<br>
>> Arizona State University<br>
>><br>
>> voice: 480-965-6262 (SHESC), 480-965-8130/727-9746 (CSDC)<br>
>> fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)<br>
>> www: <a href="http://www.public.asu.edu/~cmbarton" target="_blank">http://www.public.asu.edu/~cmbarton</a>, <a href="http://csdc.asu.edu" target="_blank">http://csdc.asu.edu</a><br>
>><br>
>><br>
>><br>
>><br>
>> Thanks César,<br>
>><br>
>> This is pretty much what I’m doing. However, it is not that simple, it<br>
>> turns out.<br>
>><br>
>> First, for a stream profile, you want to isolate a single watercourse.<br>
>> r.stream.extract creates a stream network. Getting stream order does not<br>
>> help with profiling, however.<br>
>><br>
>> I looked at r.stream.distance. But this calculates distance from each<br>
>> stream junction. I want it for the entire course of the selected<br>
>> stream—from headwaters to outlet. That is the only way to graph a stream<br>
>> profile for the entire stream.<br>
>><br>
>> Once I have a set of points with the distance from the beginning or the<br>
>> end of the line stored as an attribute for each point, the rest is easy.<br>
>> It is getting to this step that is hard.<br>
>><br>
>> If a line is composed of multiple segments—as is the case for any line<br>
>> created with r.stream.extract or r.watershed, and also with r.drain<br>
>> surprisingly—there is nothing that will ignore all of these segments and<br>
>> just give me the distance along the line from one end to the other. This<br>
>> is the case with v.to.points<br>
><br>
> As MarkusN said: you have to use v.build.polylines with cats=first, but then it is easy to get total length with v.to.db or v.to.points if that is what you need (or many other options (get end node coordinates and use v.distance 'to_along' or MarkusM's suggestion: v.net.distance from start to end node along the stream).<br>
><br>
> Here's an example in the NC dataset, using r.stream.order to approximate the main stream:<br>
><br>
> g.region n=227440 s=221640 w=630220 e=637220 res=10<br>
> r.watershed --overwrite elevation=elevation@PERMANENT threshold=10000 accumulation=accum drainage=direction stream=streams<br>
> r.stream.order --overwrite stream_rast=streams@user1 direction=direction@user1 elevation=elevation@PERMANENT accumulation=accum@user1 stream_vect=streams horton=horton<br>
> v.extract --overwrite input=streams@user1 where=horton=3 output=main_stream<br>
> v.build.polylines --overwrite input=main_stream@user1 output=main_stream_poly cats=first<br>
><br>
> then: v.to.db (result=11312.5) or<br>
><br>
> v.to.points input=main_stream@user1 output=main_stream_points dmax=1<br>
><br>
> db.select sql="select round(max(along)) from main_stream_points_2"<br>
> round(max(along))<br>
> 11312.5<br>
><br>
><br>
> Moritz<br>
<br>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
</div></div></blockquote></div><br></div>