Appearance
ST_DIFFERENCE
Returns a GEOGRAPHY representing the part of GEOGRAPHY A that does not intersect GEOGRAPHY B. This is equivalent to A - ST_INTERSECTION(A, B).
If A is completely contained within B, an empty GEOGRAPHY of the appropriate type is returned.
See also:
Syntax
sql
ST_DIFFERENCE(<a>, <b>)Arguments
<a>: TheGEOGRAPHYobject to subtract from<b>: TheGEOGRAPHYobject to subtract
Returns
Returns a GEOGRAPHY representing all parts of <a> that do not intersect with <b>
Behavior
<a> subtype | <b> subtype | Behavior |
|---|---|---|
ST_Point | ST_Point | Returns empty if <b> equals <a>, otherwise returns <a> |
ST_Point | ST_Linestring | Returns <a> if it is not on the line of <b>, otherwise empty |
ST_Point | ST_Polygon | Returns <a> if it does not intersect <b>, otherwise empty |
ST_Linestring | ST_Point | Always returns <a> |
ST_Linestring | ST_Linestring | Returns an ST_GeometryCollection of parts of <a> that are not in <b>. May return a single ST_Linestring if the lines fully overlap, except in one case |
ST_Linestring | ST_Polygon | Returns an ST_GeometryCollection of all areas of <b> that do not touch the polygon in <b> |
ST_Polygon | ST_Point | Always returns <a> |
ST_Polygon | ST_Linestring | Returns an ST_GeometryCollection containing a potentially "cut up" set of ST_polygon sliced up by the linestring in <b>. Can also return <a> if no part of <b> is inside <a>. A part of a linestring touching the polygon does not subtract from <b> |
ST_Polygon | ST_Polygon | Returns an ST_GeometryCollection slicing up <a> by the areas not in <b>. A potentially complex shape |