[postgis-users] Turn a Polygon into Lines

Kevin Neufeld kneufeld at refractions.net
Mon Mar 10 09:13:11 PDT 2008


Very nice Regina, 

I think you'll find that if you use "UNION ALL" instead of "UNION" in 
your function, you'll get better performance.  The latter computes the 
set union of the two queries, and in this case, will try to remove 
duplicate rows by comparing the bounding boxes of the linear rings.  The 
former case simply concatenates the results of one query to another.  
(Here, the set of exterior rings and interior rings should be distinct 
already)

http://www.postgresql.org/docs/8.3/static/sql-select.html#SQL-UNION

Cheers,
Kevin

Obe, Regina wrote:
> Take a look at the PostGIS wiki function fnpoly_to_rings and see if it
> does something like what you are looking for.
>
> http://postgis.refractions.net/support/wiki/index.php?plpgsqlfunctions 
>
> You might need to modify it slightly to create single lines and then the
> polygon id of left and right since it maintains the number of records
> simply by turning the MULTIPOLYGON into MULTILINESTRINGS which would
> require leaving out the ST_Collect  step and then doing an SQL update
> after the fact based on equality of line geometries.
>
> Only caveate - as some people have mentioned (generate_series degrades
> for large numbers - I haven't had big enough geometries to run into the
> issue)  .
>
> Hope that helps,
> Regina
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Lee
> Hachadoorian
> Sent: Monday, March 10, 2008 1:21 AM
> To: postgis-users at postgis.refractions.net
> Subject: [postgis-users] Turn a Polygon into Lines
>
> 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
> -----------------------------------------
> 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.
>
> _______________________________________________
> 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