Skip to main content
2 of 3
edited body
geozelot
  • 30.9k
  • 4
  • 34
  • 57

Depending on the actual similarity, you could probably get away with groups over gridded centroids, e.g.

SELECT
  ARRAY_AGG(id) AS ids,
  ST_Union(geom) AS geom
FROM
  data1
GROUP BY
  ST_SnapToGrid(ST_Centroid(geom), <grid_size>)
;

where you just need to find a suitable <grid_size> - start small (say, 0.0001 for degree based CRS), and increase slowly.

geozelot
  • 30.9k
  • 4
  • 34
  • 57