[postgis-users] grouing points on a grid

toni hernández toni at sigte.udg.edu
Wed Mar 20 04:58:08 PDT 2013


Hello,

I have 1 million points and I need to group them on a grid.
I also need to know how many of thouse points are on each cell of the grid.


My first thought was some SQL like this one:

select count(*) as n , st_snaptogrid(geom, size)
from myPoints group by st_snaptogrid(geom, size)

I thought as well about indexing myPoints table and even do some 
clustering (Cluster geom on myPoints)

Which is the best way to do this query?

Thanks in advanced


More information about the postgis-users mailing list