Returns the geometry type of a geometry object as a string prefixed with ST_.
Syntax
text ST_GeometryType(geometry g1);Parameters
| Parameter | Description |
|---|---|
g1 | The geometry object to inspect. |
Return values
Returns a string indicating the geometry type of the input. Possible values include:
ST_PointST_LineStringST_PolygonST_MultiPointST_MultiLineStringST_MultiPolygonST_GeometryCollectionST_PolyhedralSurface
Usage notes
M coordinates ignored:
ST_GeometryTypedoes not reflect whether the geometry contains M coordinates. For example, bothPOINT(1 0)andPOINTM(1 0 1)returnST_Point. To check for M coordinates, useGeometryTypeinstead.Z coordinates preserved: The function supports 3D geometries and does not drop Z coordinates.
Polyhedral surfaces supported: The function handles polyhedral surface geometries.
Examples
Point geometry:
SELECT ST_GeometryType('POINT(1 0)'::geometry); st_geometrytype
-----------------
ST_Point
(1 row)Point with M coordinates:
SELECT ST_GeometryType('POINTM(1 0 1)'::geometry); st_geometrytype
-----------------
ST_Point
(1 row)M coordinates do not affect the returned type string.
LineString geometry:
SELECT ST_GeometryType('LINESTRING(0 0, 1 1, 2 2)'::geometry); st_geometrytype
-----------------
ST_LineString
(1 row)Polyhedral surface:
SELECT ST_GeometryType(
ST_GeomFromEWKT('POLYHEDRALSURFACE(((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)))')
); st_geometrytype
--------------------
ST_PolyhedralSurface
(1 row)See also
GeometryType — Returns the geometry type as an uppercase OGC string and indicates whether M coordinates are present.