st_difference
function
Applies to: Databricks Runtime 17.1 and above
Preview
This feature is in Public Preview.
Returns the point-set difference of the two input geometries as a 2D GEOMETRY
.
Syntax
st_difference ( geoExpr1, geoExpr2 )
Arguments
geoExpr1
: The firstGEOMETRY
value.geoExpr2
: The secondGEOMETRY
value.
Returns
A value of type GEOMETRY
, representing the point-set difference of the two input geometries.
The SRID of the returned GEOMETRY
value is the common SRID of the input geometries.
The function returns NULL
if any of the inputs is NULL
.
Error conditions
- If any of the two input geometries is a geometry collection, an error is returned.
- If the two input geometries have different SRID values, the function returns ST_DIFFERENT_SRID_VALUES.
Examples
SQL
> SELECT st_astext(st_difference(st_geomfromtext('MULTIPOINT(EMPTY,4 3,5 6,-1 8)'),st_geomfromtext('POLYGON((0 0,10 0,0 10,0 0))')));
MULTIPOINT((-1 8),(5 6))