[postgis-users] Fwd: cut lines with points

2012-03-14 Thread Pedro Costa

I forget the image...



 Mensagem Original 
Assunto:cut lines with points
Data:   Wed, 14 Mar 2012 20:59:14 +
De: Pedro Costa 
Para:   postgis-users@postgis.refractions.net



Hello to all,

This is my first mail to this list.
I have to do one thing and i need help for solving that fastly.
I have points and lines and I intend to cut the lines based on points.
Does anyone have any idea how to fix this quickly?

Attached is a picture to illustrate the problem.

thank you

Pedro


<>___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Fwd: cut lines with points

2012-03-14 Thread Stephen Woodbridge
You might want to look at the book: "PostGIS In Action" pg 225 has a 
function to cut a linestring at point junctions.


Basically, you want to take your two points and construction a line like:

select astext(setsrid(makeline(pnt1, pnt2), 4326));

then get a collection of pieces of myline after we subtract your new 
line from it:


select astext(st_difference(myline, setsrid(makeline(pnt1, pnt2), 4326)));

This assumes your data is int SRID:4326, change as appropriate.

I have not tried this but give it a try and see how it works.

-Steve W

On 3/14/2012 4:59 PM, Pedro Costa wrote:

I forget the image...



 Mensagem Original 
Assunto:cut lines with points
Data:   Wed, 14 Mar 2012 20:59:14 +
De: Pedro Costa  
Para:   postgis-users@postgis.refractions.net




Hello to all,

This is my first mail to this list.
I have to do one thing and i need help for solving that fastly.
I have points and lines and I intend to cut the lines based on points.
Does anyone have any idea how to fix this quickly?

Attached is a picture to illustrate the problem.

thank you

Pedro




___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Fwd: cut lines with points

2012-03-15 Thread Sandro Santilli
On Wed, Mar 14, 2012 at 07:58:37PM -0400, Stephen Woodbridge wrote:
> You might want to look at the book: "PostGIS In Action" pg 225 has a
> function to cut a linestring at point junctions.
> 
> Basically, you want to take your two points and construction a line like:
> 
> select astext(setsrid(makeline(pnt1, pnt2), 4326));
> 
> then get a collection of pieces of myline after we subtract your new
> line from it:
> 
> select astext(st_difference(myline, setsrid(makeline(pnt1, pnt2), 4326)));

In 2.0 there's also ST_Split for that purpose.
For the cut-line-by-line case it should be faster than st_difference.
Semantic is slightly different in that you get a collection out of
ST_Split, not a multiline. 

--strk;

  ,--o-. 
  |   __/  |Delivering high quality PostGIS 2.0 !
  |  / 2.0 |http://strk.keybit.net - http://vizzuality.com
  `-o--'

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Fwd: cut lines with points

2012-03-15 Thread Pedro Costa

Em 14-03-2012 23:58, Stephen Woodbridge escreveu:
You might want to look at the book: "PostGIS In Action" pg 225 has a 
function to cut a linestring at point junctions


Thanks Steve.
I have the printed version of this book because I bought recently.
I did not remember this example but do not quite understand.
The points that I want to join share the same street number so my 
intention is to create lines with the union of points which share the 
same street, but only for those who are within a certain distance.

Will could help in building the query?

thank you
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Fwd: cut lines with points

2012-03-15 Thread Pedro Costa
I tried with the function of example, removing only the part "AND NOT 
ST_Intersects(ST_Boundary(..."

because I want the line also be cut ifintersected.

After I did so:

create table teste9 as
SELECT upgis_cutlineatpoints(passeios.the_geom, 
rebaixamentos_peoes.the_geom, 50 )

FROM passeios CROSS JOIN rebaixamentos_peoes


But did not result simply created thousands of lines of overlapping 
lines that already existed in table 'passeios'.


Can anybody help me to resolve this?

thanks








Em 14-03-2012 23:58, Stephen Woodbridge escreveu:
You might want to look at the book: "PostGIS In Action" pg 225 has a 
function to cut a linestring at point junctions.


Basically, you want to take your two points and construction a line like:

select astext(setsrid(makeline(pnt1, pnt2), 4326));

then get a collection of pieces of myline after we subtract your new 
line from it:


select astext(st_difference(myline, setsrid(makeline(pnt1, pnt2), 
4326)));


This assumes your data is int SRID:4326, change as appropriate.

I have not tried this but give it a try and see how it works.

-Steve W

On 3/14/2012 4:59 PM, Pedro Costa wrote:

I forget the image...



 Mensagem Original 
Assunto: cut lines with points
Data: Wed, 14 Mar 2012 20:59:14 +
De: Pedro Costa  


Para: postgis-users@postgis.refractions.net




Hello to all,

This is my first mail to this list.
I have to do one thing and i need help for solving that fastly.
I have points and lines and I intend to cut the lines based on points.
Does anyone have any idea how to fix this quickly?

Attached is a picture to illustrate the problem.

thank you

Pedro




___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Fwd: cut lines with points

2012-03-16 Thread Nicolas Ribot
> I tried with the function of example, removing only the part "AND NOT
> ST_Intersects(ST_Boundary(..."
> because I want the line also be cut ifintersected.
>
> After I did so:
>
> create table teste9 as
> SELECT upgis_cutlineatpoints(passeios.the_geom,
> rebaixamentos_peoes.the_geom, 50 )
> FROM passeios CROSS JOIN rebaixamentos_peoes
>
>
> But did not result simply created thousands of lines of overlapping lines
> that already existed in table 'passeios'.
>
> Can anybody help me to resolve this?
>

Hi,

Try to add a "distinct" clause in your final select to remove duplicate lines.
What is the query you are using ?

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Fwd: cut lines with points

2012-03-16 Thread Nicolas Ribot
On 15 March 2012 13:32, Pedro Costa  wrote:
> I tried with the function of example, removing only the part "AND NOT
> ST_Intersects(ST_Boundary(..."
> because I want the line also be cut ifintersected.
>
> After I did so:
>
> create table teste9 as
> SELECT upgis_cutlineatpoints(passeios.the_geom,
> rebaixamentos_peoes.the_geom, 50 )
> FROM passeios CROSS JOIN rebaixamentos_peoes
>
>
> But did not result simply created thousands of lines of overlapping lines
> that already existed in table 'passeios'.
>
> Can anybody help me to resolve this?
>

Hi,
You could try to cut the lines by yourself:

• Creates lines from points near to lines
• Group these lines by line id (one multiobject by line to cut)
• Difference these lines with the input lines, explode the result to
see elementary linestrings:

(here, query finds points closer to 150 units from the lines).

with cutters as (
select l.id, st_collect(st_makeline(p1.geometry, p2.geometry)) as geom
from points p1, points p2, lines l
where p1.id <> p2.id
and st_dwithin(p1.geometry, l.geometry, 150)
and st_dwithin(p2.geometry, l.geometry, 150)
and st_dwithin(p1.geometry, p2.geometry, 300)
group by l.id
) select distinct l.id, (st_dump(st_difference(l.geometry, c.geom))).geom
from cutters c, lines l
where st_intersects(l.geometry, c.geom);

Nicolas
<>___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users