Skip to content

ST_Zmflag

Returns a code indicating the dimension of the coordinates in a geometry.

Usage

integer ST_Zmflag(geom: geometry)

Arguments

  • geom (geometry): Input geometry

Description

Returns a code indicating the coordinate dimension:

  • 0 = 2D (XY)
  • 1 = 3D with M coordinate (XYM)
  • 2 = 3D with Z coordinate (XYZ)
  • 3 = 4D (XYZM)

Examples

2D (XY) returns 0:

SELECT ST_Zmflag(ST_GeomFromWKT('LINESTRING(1 2, 3 4)'));
┌─────────────────────────────────────────────────────────┐
│ st_zmflag(st_geomfromwkt(Utf8("LINESTRING(1 2, 3 4)"))) │
│                           int8                          │
╞═════════════════════════════════════════════════════════╡
│                                                       0 │
└─────────────────────────────────────────────────────────┘

3D with M coordinate (XYM) returns 1:

SELECT ST_Zmflag(ST_GeomFromWKT('LINESTRING M(1 2 3, 3 4 3)'));
┌───────────────────────────────────────────────────────────────┐
│ st_zmflag(st_geomfromwkt(Utf8("LINESTRING M(1 2 3, 3 4 3)"))) │
│                              int8                             │
╞═══════════════════════════════════════════════════════════════╡
│                                                             1 │
└───────────────────────────────────────────────────────────────┘

3D with Z coordinate (XYZ) returns 2:

SELECT ST_Zmflag(ST_GeomFromWKT('LINESTRING Z(1 2 3, 3 4 5)'));
┌───────────────────────────────────────────────────────────────┐
│ st_zmflag(st_geomfromwkt(Utf8("LINESTRING Z(1 2 3, 3 4 5)"))) │
│                              int8                             │
╞═══════════════════════════════════════════════════════════════╡
│                                                             2 │
└───────────────────────────────────────────────────────────────┘

4D (XYZM) returns 3:

SELECT ST_Zmflag(ST_GeomFromWKT('LINESTRING ZM(1 2 3 4, 3 4 5 6)'));
┌────────────────────────────────────────────────────────────────────┐
│ st_zmflag(st_geomfromwkt(Utf8("LINESTRING ZM(1 2 3 4, 3 4 5 6)"))) │
│                                int8                                │
╞════════════════════════════════════════════════════════════════════╡
│                                                                  3 │
└────────────────────────────────────────────────────────────────────┘