[postgis-users] Convert multipolygons to separate polygons

Bruce Raup brauplists at gmail.com
Tue Aug 19 21:05:46 PDT 2008


It's good to learn about this PostGIS solution to this.  I had need
for the same functionality, where I could control how the polygon
sub-parts inherited attributes (IDs and so on) from the "parent".  In
particular, I wanted the sub-parts to inherit all attibutes except for
one, where the sub-parts would get an attribute identifying them as a
"child".  I ended up writing a program that does this in perl, using
the Geo::Shapelib module.  I put up a project-specific web service so
that others can "flatten" their shapefiles.

It looks like this PostGIS method also causes sub-parts to inherit
attributes.  Does it?  (I'll have to upgrade before I can test this.)

Thanks,
Bruce Raup

On Tue, Aug 19, 2008 at 9:38 PM, Paragon Corporation <lr at pcorp.us> wrote:
> As Mike mentioned below - ST_Dump is probably the fastest way to do this
> (faster than ST_GeometryN if you need to dump all polygons out) and  then to
> get Point on surface - would look something like this
>
> SELECT sometable.field1, sometable.field2,
> ST_PointOnSurface((ST_Dump(the_geom)).geom) As pos
>         FROM somestatetable
>
>
> Would dump out a point on surface for each polygon in each multipolygon as
> separate records for each poly.
>
> 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
> Bresnahan, Mike
> Sent: Tuesday, August 19, 2008 6:59 PM
> To: PostGIS Users Discussion
> Subject: RE: [postgis-users] Convert multipolygons to separate polygons
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Simon O'Malley said:
>> Is there a way to split multipolygons into separate polygon features?
>>
>> Or is there a way to step through all the polygons in a multipolygon
>> and use pointonsurface to create a point for each polygon in the
>> multipolygon.
>
> ST_Dump()
> ST_NumGeometries()
> ST_GeometryN()
>
> Reference:
> http://postgis.refractions.net/documentation/manual-1.3/ch06.html
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP Universal 2.8.3
> Charset: us-ascii
>
> wsBVAwUBSKtP1h6WPRoYuvd0AQh8SggAiupcuwHjhWbmv/HQ6UIhS+VJtizQV43s
> EZTvnSXc3LFEG9sr9kCynVFuIwRjeqAf+YLF2JWaK80SR7BJqAoiLxbPdF6dtXDr
> Q2K1TiFBomwiWz/zhTRpmraXOI4GPshab1q6mGp01qkXsyt6K+bu1kKdcBIgevJ+
> 1rXc1zrjK41fec4e3Q1oKOJzNxxW0rEXn8z7pDuGVYSPUhzQyq8e9O6bB6sAq7Y0
> 42WG0N94wxDRNhSkbqVi9hMYBcwiJ1ffvEmUKCaqywCkg/xHxOXhPqVByRNGKRlJ
> pq9w3WWT4e4eNS/FGTqtf4oV+J6nSO7VtpfKSmLM9g+9jZET527Ihg==
> =4ROc
> -----END PGP SIGNATURE-----
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



-- 
Bruce Raup
http://cires.colorado.edu/~braup/



More information about the postgis-users mailing list