Skip to content
Sarah Ambrose edited this page Mar 23, 2015 · 6 revisions

Operations


ST_Aggr_ConvexHull

Overloads:

  • ST_Aggr_ConvexHull(ST_Geometry) aggregate convex hull of all geometries passed

Examples:

SELECT ST_Aggr_ConvexHull(geometry) FROM source;  -- return convex hull of all geometries in source

ST_Aggr_Intersection

Overloads:

  • ST_Aggr_Intersection(ST_Geometry) aggregate intersection of all geometries passed

Examples:

SELECT ST_Aggr_Intersection(geometry) FROM source;  -- return intersection of all geometries in source

ST_Aggr_Union

Overloads:

  • ST_Aggr_Union(ST_Geometry) aggregate union of all geometries passed

Examples:

SELECT ST_Aggr_Union(geometry) FROM source;  -- return union of all geometries in source

ST_Bin

Overloads:

  • ST_Bin(placeholder) return bin ID for given point

ST_BinEnvelope

Overloads:

  • ST_BinEnvelope(binsize, point) return bin envelope for given point
  • ST_BinEnvelope(binsize, binid) return bin envelope for given bin ID

ST_Boundary

Overloads:

  • ST_Boundary(ST_Geometry) boundary of the input ST_Geometry

Example:

SELECT ST_Boundary(ST_LineString(0,1, 1,0))) FROM src LIMIT 1;   -- MULTIPOINT((1 0),(0 1))
SELECT ST_Boundary(ST_Polygon(1,1, 4,1, 1,4)) FROM src LIMIT 1;  -- LINESTRING(1 1, 4 1, 1 4, 1 1)

ST_Buffer

Overloads:

  • ST_Buffer(geometry, distance) geometry buffered by distance

ST_ConvexHull

Overloads:

  • ST_ConvexHull(ST_Geometry, ST_Geometry, ...) returns an ST_Geometry as the convex hull of the supplied ST_Geometries

Examples:

SELECT ST_AsText(ST_ConvexHull(ST_Point(0, 0), ST_Point(0, 1), ST_Point(1, 1))) FROM onerow;
MULTIPOLYGON (((0 0, 1 1, 0 1, 0 0)))

ST_Difference

Overloads:

  • ST_Difference(ST_Geometry1, ST_Geometry2) return the difference of ST_Geometry1 - ST_Geometry2

Examples:

> SELECT ST_AsText(ST_Difference(ST_MultiPoint(1, 1, 1.5, 1.5, 2, 2), ST_Point(1.5, 1.5))) FROM onerow;
MULTIPOINT (1 1, 2 2)
> SELECT ST_AsText(ST_Difference(ST_Polygon(0, 0, 0, 10, 10, 10, 10, 0), ST_Polygon(0, 0, 0, 5, 5, 5, 5, 0))) from onerow;
MULTIPOLYGON (((10 0, 10 10, 0 10, 0 5, 5 5, 5 0, 10 0)))

ST_Envelope

Notes on Hive usage of ST_Envelope

Overloads:

  • ST_Envelope(ST_Geometry) the envelope of the ST_Geometry

Example:

SELECT ST_Envelope(ST_LineString(0,0, 2,2)) from src LIMIT 1;  -- POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))
SELECT ST_Envelope(ST_Polygon(2,0, 2,3, 3,0)) from src LIMIT 1;  -- POLYGON ((2 0, 3 0, 3 3, 2 3, 2 0))

OGC Compliance Notes :

In the case of a point or a vertical or horizontal line, ST_Envelope may either apply a tolerance or return an empty envelope.

ST_ExteriorRing

Overloads:

  • ST_ExteriorRing(polygon) return linestring which is the exterior ring of the polygon

Example:

SELECT ST_ExteriorRing(ST_Polygon(1,1, 1,4, 4,1)) FROM src LIMIT 1;  -- LINESTRING(1 1, 4 1, 1 4, 1 1)
SELECT ST_ExteriorRing(ST_Polygon('polygon ((0 0, 8 0, 0 8, 0 0), (1 1, 1 5, 5 1, 1 1))')) FROM src LIMIT 1;  -- LINESTRING (8 0, 0 8, 0 0, 8 0)

ST_InteriorRingN

Overloads:

  • ST_InteriorRingN(ST_Polygon, n) return ST_LineString which is the nth interior ring of the ST_Polygon (1-based index)

Example:

SELECT ST_InteriorRingN(ST_Polygon('polygon ((0 0, 8 0, 0 8, 0 0), (1 1, 1 5, 5 1, 1 1))'), 1) FROM src LIMIT 1;  -- LINESTRING (1 1, 5 1, 1 5, 1 1)

ST_Intersection

Notes on Hive usage of ST_Intersection

Overloads:

  • ST_Intersection(ST_Geometry1, ST_Geometry2) intersection of ST_Geometry1 & ST_Geometry2

Example:

SELECT ST_AsText(ST_Intersection(ST_Point(1,1), ST_Point(1,1))) FROM onerow; -- POINT (1 1)
SELECT ST_AsText(ST_Intersection(ST_GeomFromText('linestring(0 2, 0 0, 2 0)'), ST_GeomFromText('linestring(0 3, 0 1, 1 0, 3 0)'))) FROM onerow; -- MULTILINESTRING ((1 0, 2 0), (0 2, 0 1))
SELECT ST_AsText(ST_Intersection(ST_LineString(0,2, 2,3), ST_Polygon(1,1, 4,1, 4,4, 1,4))) FROM onerow; -- MULTILINESTRING ((1 2.5, 2 3))
SELECT ST_AsText(ST_Intersection(ST_Polygon(2,0, 2,3, 3,0), ST_Polygon(1,1, 4,1, 4,4, 1,4))) FROM onerow; -- MULTIPOLYGON (((2.67 1, 2 3, 2 1, 2.67 1)))

OGC Compliance Notes :

In the case where the two geometries intersect in a lower dimension, ST_Intersection may drop the lower-dimension intersections, or output a closed linestring.
SELECT ST_AsText(ST_Intersection(ST_Polygon(2,0, 3,1, 2,1), ST_Polygon(1,1, 4,1, 4,4, 1,4))) FROM onerow; -- MULTIPOLYGON EMPTY or LINESTRING (2 1, 3 1, 2 1)

ST_SymmetricDiff

Notes on Hive usage of ST_SymmetricDiff

Overloads:

  • ST_SymmetricDiff(ST_Geometry1, ST_Geometry2) return the symmetric difference between ST_Geometry1 & ST_Geometry2

Examples:

> SELECT ST_AsText(ST_SymmetricDiff(ST_LineString('linestring(0 2, 2 2)'), ST_LineString('linestring(1 2, 3 2)'))) FROM onerow;
MULTILINESTRING((0 2, 1 2), (2 2, 3 2))
> SELECT ST_AsText(ST_SymmetricDiff(ST_SymmetricDiff(ST_Polygon('polygon((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_Polygon('polygon((1 1, 3 1, 3 3, 1 3, 1 1))'))) from onerow;
MULTIPOLYGON (((0 0, 2 0, 2 1, 1 1, 1 2, 0 2, 0 0)), ((3 1, 3 3, 1 3, 1 2, 2 2, 2 1, 3 1)))

ST_Union

Notes on Hive usage of ST_Union

Overloads:

  • ST_Union(ST_Geometry, ST_Geometry, ...) returns an ST_Geometry as the union of the supplied ST_Geometries

Examples:

SELECT ST_AsText(ST_Union(ST_Polygon(1, 1, 1, 4, 4, 4, 4, 1), ST_Polygon(4, 1, 4, 4, 4, 8, 8, 1))) FROM onerow;
MULTIPOLYGON (((4 1, 8 1, 4 8, 4 4, 1 4, 1 1, 4 1)))
Clone this wiki locally