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

Micha Silver micha at arava.co.il
Mon Apr 18 06:55:08 EDT 2011


On 04/18/2011 12:55 PM, Moritz Lennert wrote:

> On 18/04/11 08:19, Johannes Radinger wrote:
>>
>> Am 16.04.2011 um 17:25 schrieb Daniel Victoria:
>>
>>> Not sure how to split and label the rivers but to snap the point to
>>> the closest river you could use v.distance
>>
>> I also thought about v.distance. There I get the coordinates of the
>> closest points on the new line (stdout). I just have to create a new
>> pointfile from the standard output coordinates...or is there any
>> simpler way?
> >
>> And I also still don't know how to split the lines at these points.
>> I thought about v.split but here are segemnts created at equidistant
>> breakpoints and one can only set the distance in metres but
>> it is not possible to use coordinates as input...anyone knows how
>> to do that?
>
> v.edit tool=break coords=CoordinatesOfYourPoints
>


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 :-( . I used v.what.vect 
(and v.distance directly) to get the cat values from the new points into 
the river vector line segments, but each time it gave me:

~ > v.distance from=river to=new_pts upload=cat col=pt_cat to_col=cat
  100%
  100%
1 categories exist in the table
0 records updated
v.distance complete.

But the new_pts vector has 6 cats:
~ > v.category new_pts opt=print
1
2
3
4
5
6

and the river vector has 7 segments:
GRASS 6.4.0 (WGS84):~ > v.info -t river
nodes=8
points=0
lines=7
boundaries=0
centroids=0
areas=0
islands=0
faces=0
kernels=0
primitives=7
map3d=0

So I don't know what to suggest to get the cat values from the new 
points into the river segments...

Regards,
Micha


> Moritz
>
>>
>> cheers
>> /johannes
>>
>>>
>>> Cheers
>>> daniel
>>>
>>> http://grass.fbk.eu/grass65/manuals/html65_user/v.distance.html
>>>
>>> On Thu, Apr 14, 2011 at 6:36 AM, Johannes Radinger <JRadinger at gmx.at>
>>> wrote:
>>>> Hello,
>>>>
>>>> I have a line-vector (river) and some points on that line. First I am
>>>> straightening that line with v.generalize (method: boyle). Now, there
>>>> is the problem that the points are not exactly on the line anymore.
>>>> So I want to snap (move) the points to the new generalized line
>>>> again. Which tool is able to do that?
>>>>
>>>> After that I want to split the line at these points and want to give
>>>> the attribute value to the newly created segments. These segment
>>>> values should represent the number/value of the upstream point (which
>>>> was used to split). How can this be done in GRASS?
>
>
>
>
>
>>>>
>>>> Do you have any ideas to solve these two problems/challenges?
>>>>
>>>> thank you
>>>>
>>>> /johannes
>>>> -- 
>>>> GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
>>>> gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
>>>> _______________________________________________
>>>> grass-user mailing list
>>>> grass-user at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/grass-user
>>>>
>> _______________________________________________
>> grass-user mailing list
>> grass-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
> This mail was received via Mail-SeCure System.
>
>


-- 
Micha Silver
Arava Development Co. +972-52-3665918
http://www.surfaces.co.il




More information about the grass-user mailing list