5

I have problems with the ST_ClusterDBSCAN function in PostGIS. I try to group points derived from lines with a maximum distance of 15 meters from each other and a minimum cluster size of 4. This worked fine in the past but while using the function now, it returns in most cases of my dataset NULL as CLUSTER_ID even points are in near proximity.

Here is one example:

   WITH sample_points AS(
    SELECT 
        (ST_Dump(
            ST_GeomFromText(
                'MULTIPOINT(0 0,10 10,20 20,30 30,50 50,60 60,100 0,110 0,120 0,130 0,140 0)', 3763)
            )
        ).geom 
)
SELECT ST_ClusterDBSCAN(geom, eps:=15, minpoints :=4)  over() AS cluster_id
FROM sample_points;

I get as result only NULL values.

cluster_id
NULL
NULL
NULL
NULL
[...]

This happens on my dataset, using above code or even in QGIS running DBSCAN clustering tool on manually created point layer. Am I getting something wrong about the function or why does it not work properly?

enter image description here

Running Windows10, PostgreSQL 15.1, PostGIS 3.3.2.3.3.2, QGIS 3.28.0

1 Answer 1

6

DBSCAN is a 'density-first' (my own words) algorithm, meaning that it requires a base density of minpoints (but including itself) within eps distance of each other to declare a cluster of core points - and only then border points may be added to existing clusters, if their distance is within eps of core points.

In your example there is no point that has 3 nearest neighbors within eps distance, which would be required to form an initial cluster. Simple as that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.