Operation functions
Use operation functions to perform operations on geometry data type values. For example, you can obtain the boundaries of a single geometry data type; intersections between two geometry data types; difference between left and right geometries, where each is of the same geometry data type; or an exterior buffer or ring around a particular geometry data type.
geometry_union(array(geometry))
Returns a geometry that represents the point set union of the specified geometries. Example:
SELECT geometry_union(ARRAY[ST_Point(-158.54, 61.56), ST_Point(-158.55, 61.56)])
ST_Boundary(geometry)
Takes as an input one of the geometry data types and returns the
boundary
geometry data type.
Examples:
SELECT ST_Boundary(ST_Line('linestring(0 1, 1 0)')))
SELECT ST_Boundary(ST_Polygon('polygon((1 1, 1 4, 4 4, 4 1))'))
ST_Buffer(geometry,
double)
Takes as an input one of the geometry data types, such as point, line, polygon,
multiline, or multipolygon, and a distance as type double
). Returns the
geometry data type buffered by the specified distance (or radius). Example:
SELECT ST_Buffer(ST_Point(1, 2), 2.0)
In the following example, the map coordinates are specified in longitude and
latitude, and the value .072284
, which is the buffer distance, is
specified in angular units as decimal degrees:
SELECT ST_Buffer(ST_Point(-74.006801, 40.705220), .072284)
ST_Difference(geometry, geometry)
Returns a geometry of the difference between the left geometry and right geometry. Example:
SELECT ST_AsText(ST_Difference(ST_Polygon('polygon((0 0, 0 10, 10 10, 10 0))'), ST_Polygon('polygon((0 0, 0 5, 5 5, 5 0))')))
ST_Envelope(geometry)
Takes as an input line
, polygon
, multiline
,
and multipolygon
geometry data types. Does not support
point
geometry data type. Returns the envelope as a geometry, where
an envelope is a rectangle around the specified geometry data type. Examples:
SELECT ST_Envelope(ST_Line('linestring(0 1, 1 0)'))
SELECT ST_Envelope(ST_Polygon('polygon((1 1, 1 4, 4 4, 4 1))'))
ST_EnvelopeAsPts(geometry)
Returns an array of two points that represent the lower left and upper right corners of a geometry's bounding rectangular polygon. Returns null if the specified geometry is empty. Example:
SELECT ST_EnvelopeAsPts(ST_Point(-158.54, 61.56))
ST_ExteriorRing(geometry)
Returns the geometry of the exterior ring of the input type polygon
.
Starting in Athena engine version 2, polygons are the only geometries accepted as inputs. Examples:
SELECT ST_ExteriorRing(ST_Polygon(1,1, 1,4, 4,1))
SELECT ST_ExteriorRing(ST_Polygon('polygon ((0 0, 8 0, 0 8, 0 0), (1 1, 1 5, 5 1, 1 1))'))
ST_Intersection(geometry, geometry)
Returns the geometry of the intersection of the left geometry and right geometry. Examples:
SELECT ST_Intersection(ST_Point(1,1), ST_Point(1,1))
SELECT ST_Intersection(ST_Line('linestring(0 1, 1 0)'), ST_Polygon('polygon((1 1, 1 4, 4 4, 4 1))'))
SELECT ST_AsText(ST_Intersection(ST_Polygon('polygon((2 0, 2 3, 3 0))'), ST_Polygon('polygon((1 1, 4 1, 4 4, 1 4))')))
ST_SymDifference(geometry, geometry)
Returns the geometry of the geometrically symmetric difference between the left geometry and the right geometry. Example:
SELECT ST_AsText(ST_SymDifference(ST_Line('linestring(0 2, 2 2)'), ST_Line('linestring(1 2, 3 2)')))
ST_Union(geometry,
geometry)
Returns a geometry data type that represents the point set union of the specified geometries. Example:
SELECT ST_Union(ST_Point(-158.54, 61.56),ST_LineString(array[ST_Point(1,2), ST_Point(3,4)]))