hi,Kevin,thanks for your help.<br><br>Now, I'll explain my initial motivation.<br><div class="gmail_quote">Suppose we have a table with:<br>create table houses  (     <br>   NAME              VARCHAR(128)                     not null,     <br>
);<br>SELECT AddGeometryColumn('houses', 'location', 4214, 'POINT', 2);<br>
<br>if we want to do clustering(in data mining environment) the houses on location, that is, clustering those house near as a cluster(or a group), and then calculate each cluster's shape, we can not use the following sql:<br>

<br>select ST_Boundary(*) <br>from houses<br>group by location<br><br>I would like to extend the postgresql or postgis to support the following sql:<br><br>select ST_Boundary(*) <br>from houses <br>clustering by location<br>

<br>in which the following steps are considered:<br>1. cluster the houses into several goups<br>2. calculate each goup's shape<br><br>I know the second step is usually related to aggregation functions like sum,count,and so on which i don't care too much now. All what I want to do is to add this sql semantics into postgresql or postgis and then add a clustering algorithm like dbscan in the executor in postgresql(or postgis?).<br>

How could I do? Any detailed steps?Like I should modify kwlist.h to support "CLUSTERING" keyword, and the following steps?<br><br>Thanks!<br>peng<br><br>---------------------------------------------------------------------------<br>

<br>we all know<br><br>I'm not sure I follow.  Can you explain what exactly you want to do?<br>
<br>
The following query will collect points into clusters (multipoints), clustered on a 100x100 grid.<br>
<br>
-- generate a sample random point dataset<br>
CREATE TABLE points AS<br>
SELECT ST_MakePoint(random()*1000, random()*1000) AS geom<br>
FROM generate_series(1, 100000);<br>
<br>
-- create point clusters<br>
SELECT st_collect(geom)<br>
FROM points<br>
GROUP BY<br>
   round(st_x(geom)/100)*100,<br>
   round(st_y(geom)/100)*100;<br>
<br>
<br>
Kevin<br>
<br>
<br>
On 2/4/2010 11:26 PM, sunpeng wrote:<br>
> I want to write "cluster by" instead of "group by" on geospatial point<br>
> data,should I write the code at postgresql or postgis ?<br>
> thanks<br>
><br>
> peng
</div><br>