[postgis-users] Building polygons from several line segments.

Martin Davis mbdavis at VividSolutions.com
Fri Nov 14 11:31:54 PST 2003

In the just-released JTS 1.4 there is a Polygonizer class which does exactly what you want.  JUMP also has a Polygonize tool which does this.

Not sure of timelines for porting this to GEOS.  If you grok Java you should be able to extract your geometries from PostGIS and process them using JTS. 

Martin Davis, Senior Technical Architect
Vivid Solutions Inc.
Suite #1A-2328 Government Street   Victoria, B.C.   V8T 5G5
Phone: (250) 385 6040 - Local 308      Fax: (250) 385 6046

> -----Original Message-----
> From: Bruce Saunders [mailto:brucesaunders at maximus.com]
> Sent: Friday, November 14, 2003 6:13 AM
> To: postgis-users at postgis.refractions.net
> Subject: [postgis-users] Building polygons from several line segments.
> I have a table of line segments (a la Tiger/Line data), that I would 
> like to build into the polygon objects that they represent.  
> I know how 
> to identify a group of rows that represent a single polygon.  
> I'm having 
> trouble finding a way, with the built in PostGIS/GEOS functions to 
> simplify my results to a POLYGON.  I can get the GeomUnion, 
> or collect 
> my results, but that just results in a more complex MULTILINESTRING.  
> I've tried taking the boundary of the GeomUnion or collect 
> results, but 
> that just returns "SRID=-1;MULTIPOINT(EMPTY)".  I'm on the edge of 
> coding this up myself, but I'm hoping that maybe I've missed 
> something 
> and there's an easier solution to my problem.  If not, I'd like some 
> suggestions about where in the code this would best fit (external to 
> PostGIS, part of PostGIS or part of GEOS).  Of course I'd 
> share my code 
> if I extend either GEOS or PostGIS (assuming that anyone else 
> would find 
> this useful).  Anyhow, I'd greatly appreciate any thoughts or ideas.
> Thanks a bunch.
> -Bruce Saunders
> _______________________________________________
> 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