Pular para o conteúdo principal

st_geometrytype function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 17.1 and above

Preview

This feature is in Public Preview.

Returns the type of the input GEOGRAPHY or GEOMETRY value as a string.

Syntax

st_geometrytype ( geoExpr )

Arguments

  • geoExpr: A GEOGRAPHY or GEOMETRY value.

Returns

A value of type STRING, representing the type of the input geometry.

The value returned is as follows:

  • For points, the expression returns ST_Point.
  • For linestrings, the expression returns ST_LineString.
  • For polygons, the expression returns ST_Polygon.
  • For multipoints, the expression returns ST_MultiPoint.
  • For multilinestrings, the expression returns ST_MultiLineString.
  • For multipolygons, the expression returns ST_MultiPolygon.
  • For geometry collections, the expression returns ST_GeometryCollection.

The function returns NULL if the input is NULL.

Examples

SQL
-- Returns the type of a point geometry.
> SELECT st_geometrytype(st_geomfromtext('POINT(4 5)'));
ST_Point
-- Returns the type of a geometry collection.
> SELECT st_geometrytype(st_geomfromtext('GEOMETRYCOLLECTION(POINT(4 5),LINESTRING(-4 5,7 8))'));
ST_GeometryCollection