[postgis-users] I want to write "cluster by" instead of "group by" on geospatial point data, should I write the code at postgresql or postgis ?

Kevin Neufeld kneufeld at refractions.net
Fri Feb 5 08:51:56 PST 2010


I'm not sure I follow.  Can you explain what exactly you want to do?

The following query will collect points into clusters (multipoints), clustered on a 100x100 grid.

-- generate a sample random point dataset
CREATE TABLE points AS
SELECT ST_MakePoint(random()*1000, random()*1000) AS geom
FROM generate_series(1, 100000);

-- create point clusters
SELECT st_collect(geom)
FROM points
GROUP BY
   round(st_x(geom)/100)*100,
   round(st_y(geom)/100)*100;


Kevin


On 2/4/2010 11:26 PM, sunpeng wrote:
> I want to write "cluster by" instead of "group by" on geospatial point
> data,should I write the code at postgresql or postgis ?
> thanks
>
> peng
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list