5

What is the complete list of return values for PostGIS ST_GeometryType()?

The documentation linked above only says:

Returns the type of the geometry as a string. EG: 'ST_Linestring', 'ST_Polygon','ST_MultiPolygon' etc.

I'm trying to determine the type of a geometry in a function, but couldn't find the list of all cases. (This is with PostGIS 2.5/2.4)

10

The full list of PostGIS' lwgeom type names is:

  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection
  • CircularString
  • CompoundCurve
  • CurvePolygon
  • MultiCurve
  • MultiSurface
  • PolyhedralSurface
  • Triangle
  • Tin

Also note there are two other subtle variations from this list using the two functions

Some handy tables to contrast these geometry names:

SELECT postgis_typmod_type(i),
    GeometryType((postgis_typmod_type(i) || ' EMPTY')::geometry),
    ST_GeometryType((postgis_typmod_type(i) || ' EMPTY')::geometry)
FROM generate_series(4, 63, 4) AS i;

 postgis_typmod_type |    geometrytype    |    st_geometrytype
---------------------+--------------------+-----------------------
 Point               | POINT              | ST_Point
 LineString          | LINESTRING         | ST_LineString
 Polygon             | POLYGON            | ST_Polygon
 MultiPoint          | MULTIPOINT         | ST_MultiPoint
 MultiLineString     | MULTILINESTRING    | ST_MultiLineString
 MultiPolygon        | MULTIPOLYGON       | ST_MultiPolygon
 GeometryCollection  | GEOMETRYCOLLECTION | ST_GeometryCollection
 CircularString      | CIRCULARSTRING     | ST_CircularString
 CompoundCurve       | COMPOUNDCURVE      | ST_CompoundCurve
 CurvePolygon        | CURVEPOLYGON       | ST_CurvePolygon
 MultiCurve          | MULTICURVE         | ST_MultiCurve
 MultiSurface        | MULTISURFACE       | ST_MultiSurface
 PolyhedralSurface   | POLYHEDRALSURFACE  | ST_PolyhedralSurface
 Triangle            | TRIANGLE           | ST_Triangle
 Tin                 | TIN                | ST_Tin
(15 rows)

And a full list of whatever postgis_typmod_type() spits out:

SELECT i, postgis_typmod_type(i), postgis_typmod_dims(i)
FROM generate_series(4, 63) AS i;

 i  | postgis_typmod_type  | postgis_typmod_dims
----+----------------------+---------------------
  4 | Point                |                   2
  5 | PointM               |                   3
  6 | PointZ               |                   3
  7 | PointZM              |                   4
  8 | LineString           |                   2
  9 | LineStringM          |                   3
 10 | LineStringZ          |                   3
 11 | LineStringZM         |                   4
 12 | Polygon              |                   2
 13 | PolygonM             |                   3
 14 | PolygonZ             |                   3
 15 | PolygonZM            |                   4
 16 | MultiPoint           |                   2
 17 | MultiPointM          |                   3
 18 | MultiPointZ          |                   3
 19 | MultiPointZM         |                   4
 20 | MultiLineString      |                   2
 21 | MultiLineStringM     |                   3
 22 | MultiLineStringZ     |                   3
 23 | MultiLineStringZM    |                   4
 24 | MultiPolygon         |                   2
 25 | MultiPolygonM        |                   3
 26 | MultiPolygonZ        |                   3
 27 | MultiPolygonZM       |                   4
 28 | GeometryCollection   |                   2
 29 | GeometryCollectionM  |                   3
 30 | GeometryCollectionZ  |                   3
 31 | GeometryCollectionZM |                   4
 32 | CircularString       |                   2
 33 | CircularStringM      |                   3
 34 | CircularStringZ      |                   3
 35 | CircularStringZM     |                   4
 36 | CompoundCurve        |                   2
 37 | CompoundCurveM       |                   3
 38 | CompoundCurveZ       |                   3
 39 | CompoundCurveZM      |                   4
 40 | CurvePolygon         |                   2
 41 | CurvePolygonM        |                   3
 42 | CurvePolygonZ        |                   3
 43 | CurvePolygonZM       |                   4
 44 | MultiCurve           |                   2
 45 | MultiCurveM          |                   3
 46 | MultiCurveZ          |                   3
 47 | MultiCurveZM         |                   4
 48 | MultiSurface         |                   2
 49 | MultiSurfaceM        |                   3
 50 | MultiSurfaceZ        |                   3
 51 | MultiSurfaceZM       |                   4
 52 | PolyhedralSurface    |                   2
 53 | PolyhedralSurfaceM   |                   3
 54 | PolyhedralSurfaceZ   |                   3
 55 | PolyhedralSurfaceZM  |                   4
 56 | Triangle             |                   2
 57 | TriangleM            |                   3
 58 | TriangleZ            |                   3
 59 | TriangleZM           |                   4
 60 | Tin                  |                   2
 61 | TinM                 |                   3
 62 | TinZ                 |                   3
 63 | TinZM                |                   4
(60 rows)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.