[postgis-users] Splitting a Polygon with a Linestring

Obe, Regina robe.dnd at cityofboston.gov
Wed May 28 12:02:21 PDT 2008


Kevin,
 
that looks neat.  I'll have to remember that one. 
 
I presume if you have a geometry with holes, this would not work.   How would you tackle,   if say you wanted to cut a donut with a line.
 
Thanks,
Regina

________________________________

From: postgis-users-bounces at postgis.refractions.net on behalf of Kevin Neufeld
Sent: Wed 5/28/2008 1:47 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Splitting a Polygon with a Linestring



Right.

Here's an example splitting a polygon with a line.  Note that the
dangling cutlines outside the polygon are quietly dropped.


SELECT astext(geom )
FROM dump ((

SELECT polygonize(geomunion(boundary(poly), line)) AS mpoly
FROM
   (SELECT 'POLYGON ((1 1, 1 3, 3 3, 3 1, 1 1 ))'::geometry AS poly) AS a,
   (SELECT 'LINESTRING (0 2, 4 2)'::geometry AS line) AS b

));


              astext
--------------------------------
  POLYGON((1 1,1 2,3 2,3 1,1 1))
  POLYGON((1 2,1 3,3 3,3 2,1 2))
(2 rows)

Cheers,
Kevin


James Beaudoin wrote:
> I think the steps below will work but I have one question. I am creating
> an application that allows a user to split a polygon by drawing a
> linestring across the polygon they wish to change. The crossing
> linestring has parts that are outside the polygon and I want to remove
> that before I geomunion. What's the easiest way to do that?
>
> - extract the lines that make up the polygon
> - add to this your crossing linestring
> - geomunion the lines together.
> - polygonize the union-ed set
>
> Thanks,
>
> Jim
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users




-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080528/7e0d2b77/attachment.html>


More information about the postgis-users mailing list