Impala Geospatial Functions

Impala supports a range of geospatial functions to facilitate spatial data processing and analysis, based on Apache Hive's implementation of ESRI functions.

Many functions return results in binary format (BINARY), these values can typically be interpreted as geometries, and they can be used with Hive functions similarly. It's not recommended to serialize geometries in this format, for compatibility, converting to Well-Known Binary format is recommended. Possible geometries returned as BINARY:
  • POINT
  • LINESTRING
  • POLYGON
  • MULTIPOINT
  • MULTILINESTRING
  • MULTIPOLYGON
  • GEOMETRYCOLLECTION
Coordinates for geometries may be 2D (x, y), 3D (x, y, z) or 4D (x, y, z, m). Geospatial functionality can be controlled through the startup flag GEOSPATIAL_LIBRARY.
  • By default, the library is set to HIVE_ESRI, enabling the Hive ESRI geospatial functions.
  • If geospatial functionality is not needed, it can be turned off by setting GEOSPATIAL_LIBRARY to NONE.
There are 3 types of ST_* functions:
  • Regular functions with one argument list and one return type.
  • Generic functions with multiple argument lists and overloads
  • Vararg functions with variable-length argument lists. The maximum number of arguments for vararg functions is limited to 14.
ST_Area(BINARY geometry)

Return type: DOUBLE

ST_AsBinary(BINARY geometry)

Return type: BINARY

ST_AsGeoJson(BINARY geometry)

Return type: STRING

ST_AsJson(BINARY geometry)

Return type: STRING

ST_AsShape(BINARY geometry)

Return type: BINARY

ST_AsText(BINARY geometry)

Return type: STRING

ST_Bin([BIGINT, DOUBLE] binsize, [BINARY, STRING] point)

Return type: BIGINT

ST_BinEnvelope([BIGINT, DOUBLE] binsize, [BINARY, STRING] point)

Return type: BINARY

ST_BinEnvelope([BIGINT, DOUBLE] binsize, BIGINT bin_id)

Return type: BINARY

ST_Boundary(BINARY geometry)

Return type: BINARY

ST_Buffer(BINARY geometry, DOUBLE distance)

Return type: BINARY

ST_Centroid(BINARY geometry)

Return type: BINARY

ST_Contains([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_ConvexHull(BINARY geometry...)

Return type: BINARY

ST_CoordDim(BINARY geometry)

Return type: INT

ST_Crosses([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_Difference(BINARY geometry1, BINARY geometry2)

Return type: BINARY

ST_Dimension(BINARY geometry)

Return type: INT

ST_Disjoint([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_Distance(BINARY geometry1, BINARY geometry2)

Return type: DOUBLE

ST_EndPoint(BINARY geometry)

Return type: BINARY

ST_Envelope(BINARY geometry)

Return type: BINARY

ST_EnvIntersects(BINARY geometry1, BINARY geometry2)

Return type: BOOLEAN

ST_Equals([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_ExteriorRing(BINARY polygon)

Return type: BINARY

ST_GeodesicLengthWGS84(BINARY geometry)

Return type: DOUBLE

ST_GeomCollection(STRING wkt)

Return type: BINARY

ST_GeomCollection(STRING wkt, INT wkid)

Return type: BINARY

ST_GeometryN(BINARY geometry, INT n)

Return type: BINARY

ST_GeometryType(BINARY geometry)

Return type: STRING

ST_GeomFromGeoJson(STRING geojson_string)

Return type: BINARY

ST_GeomFromJson(STRING json_string)

Return type: BINARY

ST_GeomFromShape(BINARY shape)

Return type: BINARY

ST_GeomFromShape(BINARY shape, INT srid)

Return type: BINARY

ST_GeomFromText(STRING wkt)

Return type: BINARY

ST_GeomFromText(STRING wkt, INT srid)

Return type: BINARY

ST_GeomFromWKB(BINARY wkb)

Return type: BINARY

ST_GeomFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_InteriorRingN(BINARY polygon, INT n)

Return type: BINARY

ST_Intersection([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BINARY

ST_Intersects([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_Is3D(BINARY geometry)

Return type: BOOLEAN

ST_IsClosed(BINARY geometry)

Return type: BOOLEAN

ST_IsEmpty(BINARY geometry)

Return type: BOOLEAN

ST_IsMeasured(BINARY geometry)

Return type: BOOLEAN

ST_IsRing(BINARY geometry)

Return type: BOOLEAN

ST_IsSimple(BINARY geometry)

Return type: BOOLEAN

ST_Length(BINARY geometry)

Return type: DOUBLE

ST_LineFromWKB(BINARY wkb)

Return type: BINARY

ST_LineFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_LineString(DOUBLE point1, DOUBLE point2 [, DOUBLE pointN, DOUBLE pointM]*)

Return type: BINARY

ST_LineString(STRING wkt)

Return type: BINARY

ST_M(BINARY geometry)

Return type: DOUBLE

ST_MaxM(BINARY geometry)

Return type: DOUBLE

ST_MaxX(BINARY geometry)

Return type: DOUBLE

ST_MaxY(BINARY geometry)

Return type: DOUBLE

ST_MaxZ(BINARY geometry)

Return type: DOUBLE

ST_MinM(BINARY geometry)

Return type: DOUBLE

ST_MinX(BINARY geometry)

Return type: DOUBLE

ST_MinY(BINARY geometry)

Return type: DOUBLE

ST_MinZ(BINARY geometry)

Return type: DOUBLE

ST_MLineFromWKB(BINARY wkb)

Return type: BINARY

ST_MLineFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_MPointFromWKB(BINARY wkb)

Return type: BINARY

ST_MPointFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_MPolyFromWKB(BINARY wkb)

Return type: BINARY

ST_MPolyFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_MultiLineString(STRING wkt)

Return type: BINARY

ST_MultiPoint(DOUBLE x1, DOUBLE y1, [, DOUBLE xn, DOUBLE yn])

Return type: BINARY

ST_MultiPoint(STRING wkt)

Return type: BINARY

ST_MultiPolygon(STRING wkt)

Return type: BINARY

ST_NumGeometries(BINARY geometry)

Return type: INT

ST_NumInteriorRing(BINARY polygon)

Return type: INT

ST_NumPoints(BINARY linestring)

Return type: INT

ST_Overlaps([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_Point(DOUBLE x, DOUBLE y [, DOUBLE z [, DOUBLE m]])

Return type: BINARY

ST_PointFromWKB(BINARY wkb)

Return type: BINARY

ST_PointFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_PointN(BINARY linestring, INT n)

Return type: BINARY

ST_PointZ(DOUBLE x, DOUBLE y, DOUBLE z [, DOUBLE m])

Return type: BINARY

ST_PolyFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_PolyFromWKB(BINARY wkb, INT srid)

Return type: BINARY

ST_Relate(BINARY geometry1, BINARY geometry2, STRING pattern)

Return type: BOOLEAN

ST_Polygon(DOUBLE x, DOUBLE y, [DOUBLE xn, DOUBLE yn]*)

Return type: BINARY

ST_Polygon(STRING wkt)

Return type: BINARY

ST_SetSRID(BINARY geometry, INT srid)

Return type: BINARY

ST_SRID(BINARY geometry)

Return type: INT

ST_StartPoint(BINARY linestring)

Return type: BINARY

ST_SymmetricDiff(BINARY geometry1, BINARY geometry2)

Return type: BINARY

ST_Touches([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_Union(BINARY geometry1, BINARY geometry2)

Return type: BINARY

ST_Within([BINARY, STRING] geometry1, [BINARY, STRING] geometry2)

Return type: BOOLEAN

ST_X(BINARY point)

Return type: DOUBLE

ST_Y(BINARY point)

Return type: DOUBLE

ST_Z(BINARY point)

Return type: DOUBLE