[postgis-users] 'clustering' of points

Josh Livni josh at livniconsulting.com
Fri Mar 10 14:33:39 PST 2006

Hmm, yes.  And by the way, very nice job on that.

I am not looking to render raster data, but rather get back a 'cluster' 
location (and associated points, which I forgot to mention), but your 
posts on this do seem potentially helpful.

In raster terms, I see how I could buffer each point, and create a new 
'layer' as you did, and anywhere the value was >10 or whatever, I could 
get the ID's of each point that contributed to that zone.

Of course I don't want to resort to rasters at all.  So perhaps I need 
to see whether I can create a vector layer comprised of overlapping 
point buffers, and then count aggregate overlaps to get potential 
cluster points.

Or .. I could still be missing something obvious.  So with 'kernel 
density' in mind, I'll go do a bit more research.

Thanks again,


Bill Binko wrote:
> This is somewhat related to a thread about "density mapping" that took 
> place on the mapserver list.
> http://thread.gmane.org/gmane.comp.gis.mapserver.user/16860
> My last response 
> (http://article.gmane.org/gmane.comp.gis.mapserver.user/17924) shows how 
> I accomplished a similar task, and how I would add it into Mapserver.
> One thing to note, however, is that this is for visualization, not 
> statistics.  If you're looking for "real" kernel density, a tool like R 
> or GRASS might be better.
> Bill
> Josh Livni wrote:
>> I am creating a map where it would be useful to cluster points, such 
>> that if many points were 'close' together, the map instead displays a 
>> 'cluster' point for that area.
>> Right now I have a python script that queries my postgis database for 
>> points with a bbox, and then I crudely break up the bbox into small 
>> grids, count the points within it, and if there are lots, I may 
>> replace some of those points with 'cluster' point.
>> But, this is very crude.  I am wondering if there's a clever way to 
>> make some kind of SQL query, such that if there are a 'lot' of points 
>> near a point, it will look at all 'nearby' points, and then return 
>> also 'center point' (perhaps a new point that's the average of nearby 
>> points) along with a list of points included in that 'center points' 
>> cluster.
>> And assuming there's not a pure SQL query, I am guessing this is a 
>> problem that people have looked at before, but I don't know in what 
>> context or jargon.  So, I hope the above makes sense, and someone has 
>> an algorithm or better jargon words they can point me to.
>> Thanks,
>>   -Josh
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> 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