OpenGIS proposes a number of functions that can produce geometries. They are designed to implement spatial operators.
In addition, Section 12.17.7, “Geometry Property Functions”, discusses several functions that construct new geometries from existing ones. See that section for descriptions of these functions:
These spatial operator functions are available:
ST_Buffer()
andBuffer()
are synonyms. For more information, see the description ofST_Buffer()
.Returns a geometry that represents all points whose distance from the geometry value
g
is less than or equal to a distance ofd
, orNULL
if any argument isNULL
.ST_Buffer()
supports negative distances for polygons, multipolygons, and geometry collections containing polygons or multipolygons. For point, multipoint, linestring, multilinestring, and geometry collections not containing any polygons or multipolygons,ST_Buffer()
with a negative distance returnsNULL
.ST_Buffer()
andBuffer()
are synonyms.Returns a geometry that represents the point set difference of the geometry values
g1
andg2
. If any argument isNULL
, the return value isNULL
.mysql> SET @g1 = Point(1,1), @g2 = Point(2,2); mysql> SELECT ST_AsText(ST_Difference(@g1, @g2)); +------------------------------------+ | ST_AsText(ST_Difference(@g1, @g2)) | +------------------------------------+ | POINT(1 1) | +------------------------------------+
Returns a geometry that represents the point set intersection of the geometry values
g1
andg2
. If any argument isNULL
, the return value isNULL
.mysql> SET @g1 = ST_GeomFromText('LineString(1 1, 3 3)'); mysql> SET @g2 = ST_GeomFromText('LineString(1 3, 3 1)'); mysql> SELECT ST_AsText(ST_Intersection(@g1, @g2)); +--------------------------------------+ | ST_AsText(ST_Intersection(@g1, @g2)) | +--------------------------------------+ | POINT(2 2) | +--------------------------------------+
Returns a geometry that represents the point set symmetric difference of the geometry values
g1
andg2
, which is defined as:g1 symdifference g2 := (g1 union g2) difference (g1 intersection g2)
Or, in function call notation:
ST_SymDifference(g1, g2) = ST_Difference(ST_Union(g1, g2), ST_Intersection(g1, g2))
If any argument is
NULL
, the return value isNULL
.mysql> SET @g1 = Point(1,1), @g2 = Point(2,2); mysql> SELECT ST_AsText(ST_SymDifference(@g1, @g2)); +---------------------------------------+ | ST_AsText(ST_SymDifference(@g1, @g2)) | +---------------------------------------+ | MULTIPOINT(1 1,2 2) | +---------------------------------------+
Returns a geometry that represents the point set union of the geometry values
g1
andg2
. If any argument isNULL
, the return value isNULL
.mysql> SET @g1 = ST_GeomFromText('LineString(1 1, 3 3)'); mysql> SET @g2 = ST_GeomFromText('LineString(1 3, 3 1)'); mysql> SELECT ST_AsText(ST_Union(@g1, @g2)); +--------------------------------------+ | ST_AsText(ST_Union(@g1, @g2)) | +--------------------------------------+ | MULTILINESTRING((1 1,3 3),(3 1,1 3)) | +--------------------------------------+