Tuesday, 17 March 2015

Identifying clusters in vector point data using QGIS?


I have a vector dataset of rural broadband data-points (how fast, etc.) and I'd like to explore if there are clusters of points with similar characteristics, and to plot polygons encompassing them.


For example, I may have 45,000 points in a single PostGIS dataset distributed over a landscape. I want to identify clusters which lay within x km of each other and where the speed is below y kbps, and to produce convex hulls for each qualifying cluster.


Is there a simple way of doing this in QGIS, for example?



Answer



I've combined bits from several suggestions and added a bit of my own and found a solution which works well for me - and all from within QGis!


I first ran a PostGis SELECT to find the points which have the right common attributes and lie within x km of each other:




SELECT DISTINCT s1.postcode,s1.the_geom, s1.gid FROM broadband_data AS s1 JOIN broadband_data AS s2 ON ST_DWithin(s1.the_geom, s2.the_geom,1000) WHERE s1.postcode != s2.postcode AND s1.fastest_broadband <= 2000



(Pretty much straight from Manning's very good PostGis in Action book, only adding a self-join)


I then loaded Carson Farmer's ManageR plugin, and imported the layer. From here I followed the suggested PAM clustering process here, and exported the result to a shape file, on which Convex Hulls were calculated in seconds using fTools (Carson does get around!).


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...