[postgis-users] Re: Aggregate?
Paul Ramsey
pramsey at refractions.net
Thu Mar 1 13:40:32 PST 2007
Stephen Crawford wrote:
> I don't quite understand this part:
> "Use collect(geometryn(the_geom, 1)) id your data is specified as singular
> multigeometries."
If you've loaded your data from shape files, then your POLYGON features
will all be MULTIPOLYGON by default, even if they all have only one
part. So when you Collect() them, you'll get a GEOMETRYCOLLECTION
instead of a MULTIPOLYGON.
GeometryN(the_geom,1) turns one-part MULTIPOLYGONS into simple POLYGONS,
so that when you Collect() the result is a MULTIPOLYGON.
> Also, if I want to keep a few of the record for based on another another
> value, should this work?:
>
> SELECT name, party, collect(the_geom)) AS the_geom,
> FROM constituencies
> GROUP BY constituencies.name, constituencies.party;
This will return one collection for each distinct combination of name
and party.
Paul
--
Paul Ramsey
Refractions Research
http://www.refractions.net
pramsey at refractions.net
Phone: 250-383-3022
Cell: 250-885-0632
More information about the postgis-users
mailing list