[postgis-users] species diversity query....
Gilles Bassière
gilles.bassiere at makina-corpus.com
Wed Sep 9 07:05:04 PDT 2009
Hi,
You can't mix aggregate and attribute in the SELECT clause.
In order to build one geometries from a set of geometries, you have
bassically two spatial aggregates : St_Collect() and ST_Union(). Please
refer to the documentation to choose which is more relevant to your case.
Your query would look like:
SELECT count(the_geom), ST_Union(the_geom) FROM pigs;
The result of the query is a single row with two columns. The first col
hold the number of row where the_geom is not null and the second col is
a multipolygon geometry representing all your "pigs" geometries.
Hope it helps,
Gilles
Horacio Samaniego wrote:
> Hi,
> I've been trying to devise a way to make this simple query, with no
> success. Any help will be appreciated.
>
> I have a table with multipoligons and need to generate a unique poligon
> with the count of polys. To be specific, I'm looking to generate a layer
> with species diversity based on the count of individual species
> distribution stored in a table as multipoligons.
>
> I have been trying
>
>
> SELECT count(DISTINCT id),the_geom into BIODIVERSITY FROM pigs WHERE
> the_geom && the_geom GROUP BY the_geom
>
>
> however, this obviously doesn't work...
>
> any hint from experiences queriers would be appreciated!!
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
--
Gilles Bassiere - MAKINA CORPUS
http://www.makina-corpus.com
More information about the postgis-users
mailing list