Skip to content
πŸŽ‰ SedonaDB 0.4.0 is out now! πŸ—ΊοΈ Python DataFrame API, R dplyr, Geography support & GPU-accelerated spatial joins. Read the release blog β†’

ST_Difference

Introduction: Return the difference between geometry A and B (return part of geometry A that does not intersect geometry B)

ST_Difference

Format: ST_Difference (A:geometry, B:geometry)

Return type: Geometry

Example:

SELECT ST_Difference(ST_GeomFromWKT('POLYGON ((-3 -3, 3 -3, 3 3, -3 3, -3 -3))'), ST_GeomFromWKT('POLYGON ((0 -4, 4 -4, 4 4, 0 4, 0 -4))'))

Result:

POLYGON ((0 -3, -3 -3, -3 3, 0 3, 0 -3))