[postgis-users] getting different geometries with geomunion()

Arnaud Lesauvage thewild at freesurf.fr
Thu Jul 13 03:22:41 PDT 2006


Hentschel, Markus wrote:
> With GeomUnion postgis returns one single geometry. In my case the returned geometry is a multipolygon containing multiple geometries which don't adjoin. Is it possible to get one polygon for each area? Unfortunately there is no attribute to group by. The only attribute is the geometry, but I can't use the aggregated the_geom in the GROUP BY clause.
> 
> For example, if you have a polygon database of all states of the US and your statement is this:
> 
> SELECT geomunion(the_geom)
> FROM states
> WHERE name like 'I%'
> 
> the result would be *one* multipolygon containing Illinois and Indiana, but also Idaho. How can you get seperated polygons containing only the respectively adjacent geometries?  

Hi Markus,
Have you tried the Dump() function ?

Quote from the doc :
Dump(geometry) : This is a set-returning function (SRF). It 
returns a set of geometry_dump rows, formed by a geometry (geom) 
and an array of integers (path). When the input geometry is a 
simple type (POINT,LINESTRING,POLYGON) a single record will be 
returned with an empty path array and the input geometry as geom. 
When the input geometry is a collection or multi it will return a 
record for each of the collection components, and the path will 
express the position of the component inside the collection.

http://postgis.refractions.net/docs/ch06.html#id2528926

Regards
--
Arnaud




More information about the postgis-users mailing list