6

I have a file in QGIS with 5000 points. Some of the points are really close to each other (5m). How can I cluster the point features to one point feature if they are within 5m? The new points should be centroids from the given points.

ustroetz
  • 7,994
  • 10
  • 72
  • 118

2 Answers2

11

One possible approach consists in the following steps:

  1. draw a buffer of 5m around points;
  2. dissolve the buffers which overlap;
  3. calculate the centroids of dissolved buffers.

You can choose the tools with which you're more comfortable.

Example
For instance, using GDAL >= 1.10.0 compiled with SQLite and SpatiaLite you can calculate the buffer around your points.shp:

ogr2ogr buffers.shp points.shp -dialect sqlite -sql "SELECT ST_Buffer(geometry,5) from points"

Then, calculate the clusters (dissolved buffers):

ogr2ogr clusters.shp buffers.shp -dialect sqlite -sql "SELECT ST_Union(geometry) from buffers" -explodecollections

Finally, calculate result_points.shp:

ogr2ogr result_points.shp clusters.shp -dialect sqlite -sql "SELECT Centroid(geometry) FROM clusters"
Antonio Falciano
  • 14,333
  • 2
  • 36
  • 66
1

Have a look at this tutorial: http://qgis.spatialthoughts.com/2013/04/tutorial-nearest-neighbor-analysis.html

  • Compute a Nearest Neighbour Analysis for your dataset
  • Add the resultant table into QGIS and join it to your dataset
  • Export your data into Excel and Sort/Filter it by distance.
  • Select all your data rows where the distance is <5 m
  • Select Data -> Delete duplicates
  • Import back into QGIS

Where any points are within 5 m of each other, this simple process will remove one and keep the other!

Rob Lodge
  • 837
  • 11
  • 27