[postgis-users] Splitting a Polygon with a Linestring

James Beaudoin jmbeaudoin at wisc.edu
Tue May 27 15:47:03 PDT 2008


I am having issues with splitting a polygon with a line. I do the 
intersection, then extract the lines of the polygon. Then I attempt to 
geomunion the LINESTRINGS together and get something like this

('MULTILINESTRING((597002.205895278 324851.044018193,597118.930687031 
324409.678399375,596848.325021875 323488.467624375,596980.570809376 
323238.272891265),(598023.084373772 324919.277180544,598001.418581752 
... and so on.

When I try to ST_Polygonize I get only get the original polygon and not 
the line. Is there something I am doing wrong. Below is a very general 
overview of my steps


select 
ST_AsHEXEWKB(ST_Intersection(geometryfromtext('LINESTRING(596934.688532031 
325106.344047969, 597118.930687031 324409.678399375, 596848.325021875 
323488.467624375, 597061.355013594 323085.437910313, 597061.355013594 
323085.437910313)',3071), the_geom)) from mcd_redist

select ST_AsHEXEWKB(ST_ExteriorRing(ST_GeometryN(the_geom, 
generate_series(1,ST_NumGeometries(the_geom))))) from mcd_redist

select ST_Astext(geomunion(" + myline + "," + origpoly + "))

select ST_asText(ST_Polygonize" + thedata + "))

Thanks,


Jim
Andy Anderson wrote:
> If you use ST_Intersection(geometry_line, geometry_polygon) to return 
> "a geometry that represents the point set intersection of the 
> Geometries", the user-drawn line will be truncated to just the 
> portion(s) that fall within the polygon. My tests results are either a 
> LINESTRING or MULTILINESTRING, though where I expect a POINT it 
> returns GEOMETRYCOLLECTION EMPTY (possibly due to round-off).
>
> (P.S. you'll also need to allow for the case where the user leaves one 
> end of the line inside the polygon, by extending it to the edge I 
> would imagine.)
>
> -- Andy
>
> On May 21, 2008, at 2:21 PM, 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