Bruce, Yes you can achieve that with this if you are trying to do what I think you are trying to do.
ST_Dump also makes available another variable called path, which is an array position of the location of the geometry in the master geometry. For multi geometries, the path is one dimensional, for goemetrycollections its ndimensional and I think the dimensionality depends on the complexity of your geometry collection - e.g if you have nested collections the path info would get quite interesting. For Simple shapes like POLYGON, LINESTRING, POINT the path is empty. So to take advantage of path info - its easiest to do a subselect something like this SELECT gid As parent_id, true as is_child, foo.geom As the_geom, foo.path[1] As position_in_parent FROM (SELECT sometable.gid, sometable.field1, sometable.field2, (ST_Dump(the_geom)).* FROM sometable) As foo Even for simple geometries where there is no path information - PostgreSQL would silently ignore you are trying to access an array element that doesn't exist and will just return null as I recall. Hope that helps, Regina -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bruce Raup Sent: Wednesday, August 20, 2008 12:06 AM To: PostGIS Users Discussion Subject: Re: [postgis-users] Convert multipolygons to separate polygons 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] 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 > [email protected] > http://postgis.refractions.net/mailman/listinfo/postgis-users > > > _______________________________________________ > postgis-users mailing list > [email protected] > http://postgis.refractions.net/mailman/listinfo/postgis-users > -- Bruce Raup http://cires.colorado.edu/~braup/ _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
