[postgis-users] clustering by spatial proximity

Chris Kelley iamchriskelley at gmail.com
Tue Apr 3 12:27:56 PDT 2012


Hi,

I have point data on a grid and I would like to identify and label point
clusters so that I can do a Dissolve operation and reduce the point
clusters to polygons. I can cluster the data by attribute with the very
simple:

select distinct a.id, a.the_geom from tablename a, tablename b WHERE
st_distance(a.the_geom, b.the_geom) < 0.0001 and a.grid_code > 1000;

This quickly identifies clusters of contiguous grid points with grid_code
values greater than 1000, but I don't see how to modify it to allow
distinct labeling of these clusters (like cluster1, cluster2, etc.), which
seems necessary for the subsequent Dissolve operation. Can anyone suggest a
modification to this SQL, or another statement, to cluster with labeling? I
can think of some ways to hack this together in Python but they would
likely be much less efficient.

Thanks in advance,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120403/c06c24bd/attachment.html>


More information about the postgis-users mailing list