I am trying to join some polygons using ST_Union but I am facing some problems due to slightly shifted coordinates of the polygons.

Here's an small example of two polygons I would like to merge: polygon_screen

The problem is that the lower point does not have the same longitude in the two polygons, in the first polygon it's 8.54190284185528, in the second one it's 8.54190284185522.

Due to this marginal difference St_Union returns a MultiPolygon instead of a Polygon.

Any ideas on how to fix that?

Something like the st_exteriorring (which doesn't work with MultiPolygons)?

St_ConcaveHull does not work due to some quite complicated polygons.

  • It's not actually possible to store every real value in computer representation. Your conflict is past the representation limit of an 8-byte float (and at a precision measured in angstroms). There is nothing to fix.
    – Vince
    Commented Jun 9, 2018 at 17:04
  • 1
    @Vince: actually that might be an option, cutting of the last few decimals during the import. According to wikipedia 9 decimals is an accuracy of 0.11mm, therefore it's totally unnecessary to have 14 decimals. So the solution would be ST_SnapToGrid, will try this. Commented Jun 9, 2018 at 17:28

1 Answer 1


Thanks a lot to @Vince for the hint.

Just added rounding (PostGIS: ST_SnapToGrid(geom, 0.000000001)) to my query and now it get's recognized as one polygon.

Downside of this is that my accuracy of the borders of the polygons is now 0.1 millimeter instead of 1 nanometer, but that's totally okay.

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.