# How to split a line using points?

10 messages
Open this post in threaded view
|

## How to split a line using points?

 I have points over a line and i need to split the line where the points are located. The points aren't at the same distance to each other. Any idea how to do that?Thanks in advance for your help -- David Montoya GonzálezIng. Forestal, Universidad Nacional de ColombiaLaboratorio de Sistemas Complejos, UNAL Medellin _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user points_line.png (5K) Download Attachment
Open this post in threaded view
|

## Re: How to split a line using points?

 On Thu, 14 Jun 2012, David Montoya wrote: > I have points over a line and i need to split the line where the points > are located. The points aren't at the same distance to each other. Any > idea how to do that? David,    If this is a one-off need the quickest solution might be to display the line over the points on the wxGUI display, then use the digitize function to split the line at each point. Rich _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user
Open this post in threaded view
|

## Re: How to split a line using points?

 Hi Rich, That procedure is completely impractical for me. The picture was a small example, I have 37 lines, each one with at least 500 points, that's way I need to automatize the process On Thu, Jun 14, 2012 at 10:51 AM, Rich Shepard wrote: On Thu, 14 Jun 2012, David Montoya wrote: I have points over a line and i need to split the line where the points are located. The points aren't at the same distance to each other. Any idea how to do that? David,  If this is a one-off need the quickest solution might be to display the line over the points on the wxGUI display, then use the digitize function to split the line at each point. Rich _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user -- David Montoya GonzálezIng. Forestal, Universidad Nacional de ColombiaLaboratorio de Sistemas Complejos, UNAL Medellin _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user
Open this post in threaded view
|

## Re: How to split a line using points?

 A brief suggestion, just ideas to feed your inspiration ;-) I would try to combine v.edit (tool=break) with a set of short lines created from your "fromnodes" map : we need to retrieve points coordinates, hoping they are quite coincident with lines vertices of your "fromlines" map, and create straight vector lines, each with :         * from-node=break-node         * to-node=break-node-translated-a-short-distance. Here's how I would proceed : v.out.ascii on fromnodes map. It will create a file looking like this for each feature : P  1 1  594125.63    4921115.58  1     1 then you can turn it (through a script for the huge number of points you deal with) into : L  2 1  594125.63    4921115.58  594125.63    4921116.58  1     1 (in this example the short line is pointing 1 m towards north from the initial point) Then put back these lines in a "cuts" line map (v.in.ascii). Run v.edit to make sure frompoints and lines vertices match : v.edit map=cuts type=line tool=move move=0,0 thresh=-1,,0 where="" bgmap=fromlines snap=node Finally run again v.edit to break lines at intersections (didn't check if bgmap applies to break tool, you need to check) : v.edit map=fromlines type=line tool=break where="" bgmap=cuts Good luck! Vincent _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user
Open this post in threaded view
|

## Re: How to split a line using points?

 In reply to this post by David Montoya ------------------------------------------------------------ I have points over a line and i need to split the line where the points are located. The points aren't at the same distance to each other. Any idea how to do that? If your points lie exactly on the line, you may do so (in Linux with bash) :v.out.ascii format=point in=pts --q | cut -d'|' -f1,2 | tr '|' ',' | while read COOR; do v.edit map=line tool=break coords=\$COOR; done ------------------------------------------------------------ _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user
Open this post in threaded view
|

## Re: How to split a line using points?

 In reply to this post by David Montoya On 06/14/2012 06:46 PM, David Montoya wrote: I have points over a line and i need to split the line where the points are located. The points aren't at the same distance to each other. Any idea how to do that? I think that: v.edit tool=break coord=... will do that. If you're sure that the points indeed fall exactly on the line, then dump the coordinates to a text file (v.out.ascii) then loop thru that file, and feed the coords to v.edit, like so v.out.ascii out=points.txt while read x y; do     v.edit tool=break coord=\$x,\$y cat=0-99999 done < points.txt Be aware that the tool=break is actually breaking the line into two at each point. There's also tool=vertexadd if you only need to add a vertex along the line, rather than actually splitting it. -- Micha Thanks in advance for your help -- David Montoya González Ing. Forestal, Universidad Nacional de Colombia Laboratorio de Sistemas Complejos, UNAL Medellin This mail was received via Mail-SeCure System. ```_______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user This mail was received via Mail-SeCure System. ``` ```-- Micha Silver GIS Consultant, Arava Development Co. http://www.surfaces.co.il``` _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user
Open this post in threaded view
|

## Re: How to split a line using points?

 Thanks for all your suggestions, they help me to solve my problemOn Thu, Jun 14, 2012 at 2:24 PM, Micha Silver wrote: On 06/14/2012 06:46 PM, David Montoya wrote: I have points over a line and i need to split the line where the points are located. The points aren't at the same distance to each other. Any idea how to do that? I think that: v.edit tool=break coord=... will do that. If you're sure that the points indeed fall exactly on the line, then dump the coordinates to a text file (v.out.ascii) then loop thru that file, and feed the coords to v.edit, like so v.out.ascii out=points.txt while read x y; do     v.edit tool=break coord=\$x,\$y cat=0-99999 done < points.txt Be aware that the tool=break is actually breaking the line into two at each point. There's also tool=vertexadd if you only need to add a vertex along the line, rather than actually splitting it. -- Micha Thanks in advance for your help -- David Montoya González Ing. Forestal, Universidad Nacional de Colombia Laboratorio de Sistemas Complejos, UNAL Medellin This mail was received via Mail-SeCure System. ```_______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user This mail was received via Mail-SeCure System. ``` ```-- Micha Silver GIS Consultant, Arava Development Co. http://www.surfaces.co.il``` -- David Montoya GonzálezIng. Forestal, Universidad Nacional de ColombiaLaboratorio de Sistemas Complejos, UNAL Medellin _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user
Open this post in threaded view
|

## Re: How to split a line using points?

 DoneOn Sat, Jun 16, 2012 at 2:21 AM, Markus Neteler wrote: David, would you mind to make it a short Wiki FAQ article? http://grass.osgeo.org/wiki/Faq There are some examples: http://grass.osgeo.org/wiki/Category:Vector thanks Markus On Thu, Jun 14, 2012 at 10:04 PM, David Montoya <[hidden email]> wrote: > Thanks for all your suggestions, they help me to solve my problem > > -- David Montoya GonzálezIng. Forestal, Universidad Nacional de ColombiaLaboratorio de Sistemas Complejos, UNAL Medellin _______________________________________________ grass-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/grass-user