[postgis-users] Turn a Polygon into Lines

Martin Davis mbdavis at refractions.net
Mon Mar 10 11:23:30 PDT 2008


It sounds like what you are looking for is a way to turn a set of 
non-overlapping polygons and turn them into a polygonal coverage (or at 
least produce the arcs in that coverage).

I don't think there's any easy way of doing this in PostGIS.  I'm not 
sure that Regina's & Kevin's suggestions will produce the non-shared, 
unique node-to-node arcs that are required.

The usual algorithm for doing this is:
- extract all line segments from each input polygon, labelled with the 
polygon ID on the appropriate side
- merge duplicate segments, also merging the labels (on the appropriate 
side).  To identify duplicate segments and merge them, segments will 
need to be reoriented so that they are in a consistent direction (and 
the labels flipped accordingly)
- "sew" the resulting set of line segments together to create linestring 
edges from 3-node to 3-node  (e.g. eliminating "non-topologically 
significant" 2-nodes

You might be able to create some SQL and/or stored proc code to do this 
- it would be interesting to see how complicated and performant this 
would be.

Lee Hachadoorian wrote:
> I'm looking through the PostGIS reference, and I can't seem to find a 
> way to take a geometry of polygons and turn it into lines.  What I'm 
> looking for is something like the ArcGIS Feature to Line geoprocessor, 
> which will create a line shapefile where each feature is an arc 
> representing the boundary between neighboring polygons with a field 
> indicating the ids of the polygon on either side.
>
> Functions like ST_MakeLine require point geometries, and I don't see 
> anything else that seems to be what I'm looking for.  Any ideas would 
> be welcome.
>
> Thanks,
> Lee Hachadoorian
> PhD Student in Geography
> Program in Earth & Environmental Sciences
> CUNY Graduate Center
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-users mailing list