[postgis-users] Splitting a Polygon with a Linestring

Kevin Neufeld kneufeld at refractions.net
Wed May 28 10:47:22 PDT 2008


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



More information about the postgis-users mailing list