[postgis-users] 'Clustering' records in space and time

William Furnass will at thearete.co.uk
Thu Jul 15 07:05:35 PDT 2010

I have a PostGIS table of records describing events therefore the
table has a timestamp attribute.  I wish to replace 'clusters' of
events that occur within a m-hour window and a spatial radius of n
with single events which have the mean timestamp and central position
of the cluster.  I understand that I can quantize my data spatially
using the St_SnapToGrid function but using this function alone I lose
some of the distinct events that occurred at the same point in space
but at very different times (it's my understanding that St_SnapToGrid
only allows one point to be stored at each node in the grid).  Also, I
am unsure as to how I could use St_SnapToGrid in such a way so as not
to relocate points that are unique within the aforementioned spatial
and temporal window boundaries.

Has anyone any suggestions as to how this can be achieved
programmatically using SQL (rather than a graphical tool)?  Should I
perhaps be looking to use R to spatially and temporally cluster my
data?  Apologies if the description of my problem isn't particularly
clear; it's been a long day:)

More information about the postgis-users mailing list