Quantcast

How to split a line using points?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to split a line using points?

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?

Thanks in advance for your help

--
David Montoya González
Ing. Forestal, Universidad Nacional de Colombia
Laboratorio 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

Rich Shepard
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

David Montoya
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 <[hidden email]> 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ález
Ing. Forestal, Universidad Nacional de Colombia
Laboratorio de Sistemas Complejos, UNAL Medellin


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

Vincent Bain
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,<reasonable snap
distance>,0 where="<a statement selecting all lines>" 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="<a statement selecting
all lines>" bgmap=cuts

Good luck!

Vincent



_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

amuriy
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

Micha Silver
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 <your line> 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 <your points> out=points.txt
while read x y; do
    v.edit <your line> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

David Montoya
Thanks for all your suggestions, they help me to solve my problem

On Thu, Jun 14, 2012 at 2:24 PM, Micha Silver <[hidden email]> 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 <your line> 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 <your points> out=points.txt
while read x y; do
    v.edit <your line> 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ález
Ing. Forestal, Universidad Nacional de Colombia
Laboratorio de Sistemas Complejos, UNAL Medellin


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

David Montoya
Done

On Sat, Jun 16, 2012 at 2:21 AM, Markus Neteler <[hidden email]> 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ález
Ing. Forestal, Universidad Nacional de Colombia
Laboratorio de Sistemas Complejos, UNAL Medellin


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

Markus Neteler
[to add a Wiki FAQ]

On Tue, Jun 19, 2012 at 10:27 PM, David Montoya <[hidden email]> wrote:
> Done

Great: http://grass.osgeo.org/wiki/Vector_add_multiple_vertices

thanks,
Markus
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to split a line using points?

cnoeliachaves
This post has NOT been accepted by the mailing list yet.
Hi!

I tried with this code:

coords_add=`v.out.ascii Bifurcaciones |cut -d "|" -f1,2 | tr "|" ","`
 
for i in $coords_add ; do
v.edit map=red tool=break coords=$i
done

But I have the error:

ADVERTENCIA: Ningún elemento seleccionado, nada que editar
Construyendo topología para el mapa vectorial <red@noelia>...
Registrando primitivas...
v.edit: spindex_rw.c:1364: rtree_get_node: La declaración `t->nb[level][which].n.level == level' no se cumple.
Abortado (`core' generado)
Seleccionando elementos...
0 of 46 features selected from vector map <red@noelia>
ADVERTENCIA: Ningún elemento seleccionado, nada que editar
Construyendo topología para el mapa vectorial <red@noelia>...
Registrando primitivas...
v.edit: spindex_rw.c:1364: rtree_get_node: La declaración `t->nb[level][which].n.level == level' no se cumple.
Abortado (`core' generado)

Can you help me ? Thanks
Loading...