[GRASS-user] snap point to line/break line at given points

Johannes Radinger JRadinger at gmx.at
Fri Apr 22 05:34:52 EDT 2011


Am 18.04.2011 um 13:40 schrieb Micha Silver:

> On 04/18/2011 01:55 PM, Micha Silver wrote:
>> 
>> 
>> Maybe a few more details might be helpful:
>> If you want to first get the coordinates of the new points along the (simplified) river line,
>> (starting with a line vector 'river' and a set of points 'old_pts' displaced from the line) you first do:
>> 
>> ~>v.db.addtable old_pts col="x double precision, y double precision"
>> 
>> then:
>> 
>> ~>v.distance --o to=river from=old_pts out=connectors upload=to_x,to_y col=x,y
>> 
>> This puts the *new* X-Y coordinates of points exactly on the river, and at the node of perpendicular 'connectors' from the old points to the river into the old_pts attribute table.
>> Now:
>> 
>> ~>v.db.select -c old_pts col=x,y >new_pts.txt
>> ~>v.db.select -c old_pts fs=, col=x,y | v.in.ascii  out=new_pts
>> 
>> THis gives you both a new point vector of the points along the river, and a text file of their coordinates. Next, I used Moritz's method to split the river at these new points, in a loop like:
>> 
>> ~>while read coord; do v.edit river tool=break coord=$coord; done < new_pts.txt
>> 
>> This leaves you with a multi-segment line vector, split at the new points.
>> 
>> 
>>> v.net option=connect + some cleaning afterwards might be another possible solution. For each point, it will create a line connecting it to the river, breaking the river at the intersection.
>>> 
>>> v.distance should be able to do the labelling for you.
>>> 
>> 
>> I tried this part, but couldn't get it to work :-( .
> ....
>> 
>> So I don't know what to suggest to get the cat values from the new points into the river segments...
>> 
> 
> 
> Update:
> I have found a kind of work around to get the same cat values in both the points and river segments, although it's a bit "backwards". THe modules v.distance and v.what.vect can only connect from a point vector to another line or area vector. Then values from the "to" (line or area) can be uploaded to the points. So if I reset the categories in the river line vector - so that each segment has it;s own cat, then I can upload those cat values into the new points vector. Here's the procedure:
> 
> FIrst blow away the existing categories in the river vector and recreate a new vector with new category values:
> 
> ~>v.category river opt=del out=river2 --o
> ~ > v.db.droptable -f river2
> ~ > v.db.addtable river2
> ~ > v.category river2 out=river3 --o
> 
> Now river3 should contain a new cat value, one for each line segment. Check with:
> 
> ~ > v.category river3 opt=print
> 1
> 2
> 3
> .....

Somehow that isnt' working in my case. 

About my situation: I've got a river network, which
is a polylinefeature set with 43 lines (43 IDs) included (tree-like shape of a rivernet)
all with the same cat-value (1).

Now I would like to unite/merge the lines to one feature (1 ID) if that is possible
and break that single element at given points with v.edit...Because if I break
now at around 40 positions I get over 80 segements (40 old segements and which
are broken again at different positions) but there should  be only 
41 or so...

so how can I handle that and assign unique cat values for each segment...(at the
moment the don't have to be the same like the breakpoints, just unique values)

any suggestions?

/johannes

> 
> And finally:
> ~ > v.db.addcol new_pts col="river_cat integer"
> ~ > v.what.vect vect=new_pts col=river_cat qvect=river3 qcol=cat dmax=0.01
> 
> creates a new column in the new_pts vector attrib table called 'river_cats' with values matching the adjacent river segment.
> 
> Regards,
> Micha
> 
>> Regards,
>> Micha
>> 
> 
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user



More information about the grass-user mailing list