I'm fighting against some ST_Intersect operations that returns, sometimes, topology errors.

I've been running ST_makevalid for all the goemetries that apparently have the errors, but still the error in ST_Intersects appears.

I'd like to know how ST_Intersects does behind the scenes, and if there is a way to change the internal parameters to avoid (or discovery) excactly where the errors happen.

  • 2
    Have you tried st_snaptogrid, and/or buffering with a very small distance? It sometimes fix geometry errors that makevalid misses
    – BERA
    Feb 14, 2022 at 9:30
  • 1
    I have had issues with geography and polygon whose inner ring touches the outer ring, with no vertex on the outer ring. Because of the geography type, a reprojection is done and can lead to the "intersection" point between the 2 rings to move outside of the polygon, which is an error. The original polygon is valid though! The solution was to apply a buffer of 0 to add the missing vertex on the outer ring.
    – JGH
    Feb 14, 2022 at 14:24
  • Can you post an example? And/or open a PostGIS ticket.
    – dr_jts
    Feb 25, 2022 at 3:03

1 Answer 1


PostGIS geometry operations are performed with the GEOS library[1], a C++ port of the JTS library.

The JTS documentation describes which algorithms are used for the different geometry processing operations. I have not found equivalent information in the GEOS documentation. But as GEOS is a JTS port, it's likely that the informations given in the JTS documentation is also true for GEOS.

[1]: Or the SFCGAL library, but this requires specific settings.

  • 1
    Should this be taken to mean that st_intersects is not really safe to use on polygons on the surface of a spherical or ellipsoidal Earth? GEOS assumes a 2D Cartesian coordinate system, so it would be using longitude as "x" and latitude as "y". Apr 18, 2023 at 18:57

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.