Skip to main content
21 votes

Clustering spatial data in R?

Here is a solution based on Find clusters of points based distance rule, but using the distm function from the geosphere package: library(sp) library(rgdal) library(geosphere) # example data from ...
ssanch's user avatar
  • 341
21 votes
Accepted

Converting cluster of Points to Polygons using QGIS

Convex hull - as mentioned by Kazuhito - is one option, but - depending on the cluster shape - you will get more appropriate polygons using concave hulls, for example implemented in ConcaveHull plugin....
underdark's user avatar
  • 84.2k
13 votes

Clustering points/polygons based on proximity (within specifed distance) using QGIS?

you can try this (did this in QGIS 2.16) fixed distance buffer each point by 250m (this is half the required distance between points) then dissolve all on the result of that then use multipart to ...
Steven Kay's user avatar
  • 20.4k
13 votes

Clustering points in PostGIS

I'd suggest to use the ST_ClusterDBSCAN Window function rather than the Aggregate function ST_ClusterWithin: SELECT *, ST_ClusterDBSCAN(the_geom, eps := <distance>, minpoints := 1) OVER()...
geozelot's user avatar
  • 30.3k
11 votes

Spatial clustering with PostGIS?

You can use Kmeans solution more easily with ST_ClusterKMeans method that's available in postgis from 2.3 Example: SELECT kmean, count(*), ST_SetSRID(ST_Extent(geom), 4326) as bbox FROM ( ...
volda's user avatar
  • 383
11 votes
Accepted

Clustering undirected lines

If I understand you right you want to cluster lines that is about the same without respect to direction. Here is an idea that I think could work. split the lines in start point and end point Cluster ...
Nicklas Avén's user avatar
11 votes

Generating urban footprint polygons from building clusters in QGIS?

I was able to get some quite good results, with thanks to Michael Stimson for the suggestion. I had forgotten about the "buffer out, buffer back in" trick (this can also help reduce the number of ...
Steven Kay's user avatar
  • 20.4k
11 votes
Accepted

Point Clustering in QGIS, but values show a percentage and not count of points

The displayed number is part of the point clustering symbol. To modify it, click on the cluster symbol: Then select the font marker and click the epsilon for the character data override: Edit it and ...
JGH's user avatar
  • 42.1k
10 votes
Accepted

Birch algorithm does not cluster as expected

I've done some research. I took some points in two coordinate systems non metric (WGS84) and metric (Poland 1992). I used this code: from scipy import loadtxt from sklearn.cluster import Birch ...
dmh126's user avatar
  • 6,742
10 votes

Converting cluster of Points to Polygons using QGIS

You may be interested in Convex Hull which is in Processing | QGIS geoalgorithms | Vector geometry tools. There is Field option which can be used with Method Create convex hulls based on field. Or ...
Kazuhito's user avatar
  • 30.9k
10 votes
Accepted

Points Clustering - QGIS 3.18

You can do the first by creating bins in a new field with the expression ceil(id/30) Where id is your sequential field. This returns 1 for the first 30 points, 2 for points 31-60 and so on. Then, go ...
Encomium's user avatar
  • 3,143
8 votes
Accepted

Using ST_ClusterDBSCAN on results of ST_ClusterKMeans for nested clustering with PostGIS?

Interesting idea. I think you can most easily accomplish this by delaying creation of the MultiPoint geometries until after your data has made it through both clustering algorithms. First, assign a ...
dbaston's user avatar
  • 13.1k
8 votes
Accepted

QGIS 3.10 - Point cluster symbology sum attribute

Open your symbology menu and click on your cluster symbol: Now click on 'Font Marker' and scroll down to 'Character(s)': Edit the data defined override and insert this expression, if your points ...
MrXsquared's user avatar
  • 34.5k
8 votes
Accepted

Adding Weight Data to Points in QGIS

If you want to change the size of a point symbol according to an attribute value, click the data driven override icon next to the size setting of the layer's Layer Styling panel and select assistant: ...
Babel's user avatar
  • 71.6k
7 votes

Clustering of Spatial Data in R or Python

There are an extremely large number of approaches to clustering, and your question is not answerable, short of writing a textbook describing all possible methods. Therefore, the question I will answer ...
Lee Hachadoorian's user avatar
7 votes
Accepted

Label display based on cluster size

The variables @cluster_color and @cluster_size only exist in the context of the cluster renderer. They cannot be used in expressions for labeling. To label point clusters based on these variables, we ...
csk's user avatar
  • 24.9k
7 votes

Clustering point data in QGIS?

You can do this with the "point cluster" symbology. Before: Rightclick on your point layer -> Properties... -> Symbology -> and chose "Point cluster" Close points (you can define this parametre) ...
Christophe P.'s user avatar
7 votes
Accepted

Clustering points and summing up attributes per cluster in QGIS

I would try K-means clustering algorithm in the QGIS Processing Toolbox (under Vector analysis group). Just by setting the Number of clusters as 4, it will produce a new Clusters layer with an ...
Kazuhito's user avatar
  • 30.9k
7 votes
Accepted

Dividing Polygon into parts which have equal area using R

As I needed something similar, I wrote a small function for R following the steps of this question on "Splitting polygon into equal area polygons using QGIS" I hope this helps somebody, even ...
Geoline's user avatar
  • 86
7 votes

PostGIS: Interpolate/Cluster geographic points to average points

A solution using PostGIS alone. The Steps are as follows: Generate clusters from the points Get the centre of each point cluster Generate a line that connects each cluster centre point (will also ...
Cushen's user avatar
  • 2,928
7 votes
Accepted

Differentiating with unique id overlapping/intersecting or isolated convex_hulls in QGIS

To "cluster" several polygons that (partially) overlap into one contiguous polygon with Geometry Generator, first collect all polygons, then buffer them with 0. As this would produce the ...
Babel's user avatar
  • 71.6k
6 votes

Clustering undirected lines

Do you really want to cluster solely by direction, without any consideration of origin or destination? If so, there are some very simple ways. Perhaps the easiest is to compute the bearing of each ...
whuber's user avatar
  • 69.9k
6 votes

Openlayers 4 Cluster polygons

I found the solution myself, the original features that make up the clustered feature are stored in a property called "features". My zoomed in style becomes: var zoomedInStyle = new ol.style.Style({ ...
user613068's user avatar
6 votes
Accepted

Clustering neighboring points inside ArcGIS Desktop?

Result of clustering technique suggested by @Albert shown by colours of points in the picture below. Output will greatly depend on physical order of points in a feature class. At some stage it will ...
FelixIP's user avatar
  • 23.1k
6 votes

QGIS 3.0 point cluster renderer, is it possible to control rendering order (z-order)?

It seems as though the point cluster implementation does not allow for this natively. Consider the point cluster renderer - it essentially analyzes and clusters point data at render time, creating a ...
CrystallineEntity's user avatar
6 votes
Accepted

Natural Breaks Results Difference in Different GIS Analyst Tools

The first question to investigate is, what method are these programs using to calculate Natural Breaks? Are they all using the same method? QGIS calculates Natural Breaks (Jenks). Based on the name "...
csk's user avatar
  • 24.9k
6 votes

Aggregate multiple image class values into a single class (Earth Engine)

Use the remap function. Just to give you an example, here I remapped your band values to ones and other values to zeros. // merge several clusters together // Define your from and to values var ...
Kuik's user avatar
  • 10.1k
6 votes
Accepted

Is "order by" clause in DBSCAN necessary?

It's not necessary to obtain a correct result. But because DBSCAN may have multiple valid solutions for a given set of inputs, the ordering may be necessary to obtain a stable result (i.e., the same ...
dbaston's user avatar
  • 13.1k
5 votes
Accepted

Spatial clustering with PostGIS including attributes

To answer your main question, to cluster by attributes, you simply use GROUP BY attribute. AS ST_ClusterWithin will operate on any geometry type, it returns a GeometryCollection. To only pull out ...
John Powell's user avatar
  • 13.7k
5 votes

Creating polyline-based "heatmap" from GPS tracks?

Here is my approach on QGIS. This was for a set of bus routes, and I wanted to identify which roads had the most density of bus routes passing by. Used the Qchainage plugin to convert my lines into ...
Diego canales's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible