[postgis-users] Fwd: cut lines with points

Nicolas Ribot nicolas.ribot at gmail.com
Fri Mar 16 08:49:48 PDT 2012

On 15 March 2012 13:32, Pedro Costa <pedrocostaarma at sapo.pt> 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?

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);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen shot 2012-03-16 at 4.45.05 PM.png
Type: image/png
Size: 22984 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120316/74758d77/attachment.png>

More information about the postgis-users mailing list