[postgis-users] Grouping points into a polygon with aggregate counts

Tim Robertson trobertson at gbif.org
Tue Apr 10 03:13:53 PDT 2007


Hi All,

 

I'm a newbie and as such, this is a newbie kind of question

 

I have 2 tables:

 

o (id, name, geom(point))

s (id, count, geom(polygon))

 

I have o populated with millions of records

 

I want to populate s with aggregate counts by 1 degree box.  That is to say
it will have a polygon representing a 1x1 deg bound box and the count of "o"
within the box.

 

Can someone help me with the SQL to populate the s table please?

 

e.g. something like

 

insert into s(count, geom)

select count(id) from o, GEOM_AS_1_X_1_BOX??? from o group by 2;

 

(not sure this is SQL92 sql - I am a Mysql person.)

 

Many thanks

 

Tim

p.s. - new to Postgres too.

            

            

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070410/b76d2cde/attachment.html>


More information about the postgis-users mailing list