Hello everyone!
I'm trying to get to know if it's possible to cluster (combine with the same e.g. cluster_id field) points that are lying within some distance to each other and additionally have the same, selected attributes.
For example I have PostGIS data containing buildings as points. Some of them have the same elevation and are very close to each other, due to the fact that someone entered them like this.
I need to make my data smaller by grouping them, but only if they are close to each other AND have the same elevation (to be sure that I've grouped points standing for the same building.
Here's example which I've been able to achieve for now using PostGIS only:
select geom, point_id, height_ft, elevation_ft, obstacle_type, clst_id
into output_table_name
from
(
SELECT geom, point_id, height_ft, elevation_ft, obstacle_type,
ST_ClusterDBSCAN(geom, eps := 0.0003, minpoints := 1) OVER() AS clst_id
FROM (select geom, point_id, height_ft, elevation_ft, obstacle_type from input_table where country_code = 'ARE') y
) x
As you can see its only taking into account the proximity. Coordinate system is WGS84 so I've put as proximity distance parameter 0.0003, which should be less than 50 meters in ground units.
I'd like to distinguish those groups also by common elevation.
I'd be grateful for any directions.