Geospatial User Guide > Geospatial User Guide > Geospatial Functions > GeometryMFromWKB GeometryZFromWKB
Was this helpful?
GeometryMFromWKB
GEOMETRYMFROMWKB(b binary [, srid integer])
Alias: GEOMMFROMWKB, ST_GEOMETRYMFROMWKB, ST_GEOMMFROMWKB
Returns a geometry object that corresponds to the Well Known Binary (WKB) representation of the object given in b. The srid specifies the object's SRID. If left unspecified, the SRID returns -1. This function only supports geometries with M coordinates.
Result type: geometry
Examples:
How do I insert results from ASBINARY into GEOMMFROMWKB manually (for example, copy ASBINARY results and paste into GEOMMFROMWKB)?
First specify the point using GEOMMFROMTEXT, then get the binary representation using ASBINARY, then specify the point using GEOMMFROMWKB, and then display the point as text using ASTEXT.
SELECT ASTEXT(GEOMMFROMWKB(ASBINARY(GEOMMFROMTEXT('POINT M(1 2 2)'))));
--------------------------------
col1
--------------------------------
POINT M (1 2 2)
--------------------------------
SRID of a point when it is not specified.
SELECT SRID(GEOMMFROMWKB(ASBINARY(GEOMMFROMTEXT('POINT M(1 2 2)'))));
-------------
col1
-------------
-1
-------------
SRID of a point when it is specified.
SELECT SRID(GEOMMFROMWKB(ASBINARY(GEOMMFROMTEXT('POINT M(1 2 2)')), 4955));
-------------
col1
-------------
4955
-------------
GeometryN
GEOMETRYN(g Geometrycollection, n interger)
Alias: ST_GEOMETRYN
Returns the nth object from g.
Result type: geometry
Example:
SELECT ASTEXT(GEOMETRYN(MLINEFROMTEXT('MULTILINESTRING((1 1, 9 1), (2 2, 8 2))'), 2));
--------------------------------
col1
--------------------------------
LINESTRING (2 2, 8 2)
--------------------------------
GeometryType
GEOMETRYTYPE(g Geometry)
Alias: ST_GEOMETRYTYPE
Returns the type of g.
Result type: string
Example:
Query the type of a shape:
SELECT GEOMETRYTYPE(POLYFROMTEXT('POLYGON((0 0, 0 20, 15 20, 15 0, 0 0))'));
------------------------------
col1                          
------------------------------
POLYGON                       
------------------------------
GeometryZFromText
GEOMETRYZFROMTEXT(s string [, srid integer])
Alias: GEOMZFROMTEXT, ST_GEOMETRYZFROMTEXT, ST_GEOMZFROMTEXT
GeometryZFromWKB
GEOMETRYZFROMWKB(b binary [, srid integer])
Alias: GEOMZFROMWKB, ST_GEOMETRYZFROMWKB, ST_GEOMZFROMWKB
Returns a geometry object that corresponds to the Well Known Binary (WKB) representation of the object given in b. The srid specifies the object's SRID. If left unspecified, the SRID returns -1. This function only supports geometries with Z coordinates.
Result type: geometry
Examples:
How do I insert results from ASBINARY into GEOMZFROMWKB manually (for example, copy ASBINARY results and paste into GEOMZFROMWKB)?
First specify the point using GEOMZFROMTEXT, then get the binary representation using ASBINARY, then specify the point using GEOMZFROMWKB, and then display the point as text using ASTEXT.
SELECT ASTEXT(GEOMZFROMWKB(ASBINARY(GEOMZFROMTEXT('POINT Z(1 2 2)'))));
--------------------------------
col1
--------------------------------
POINT Z (1 2 2)
--------------------------------
SRID of a point when it is not specified.
SELECT SRID(GEOMZFROMWKB(ASBINARY(GEOMZFROMTEXT('POINT Z(1 2 2)'))));
-------------
col1
-------------
-1
-------------
SRID of a point when it is specified.
SELECT SRID(GEOMZFROMWKB(ASBINARY(GEOMZFROMTEXT('POINT Z(1 2 2)')), 4955));
-------------
col1
-------------
4955
-------------
GeometryZMFromText
GEOMETRYZMFROMTEXT(s string [, srid integer])
Alias: GEOMZMFROMTEXT, ST_GEOMETRYZMFROMTEXT, ST_GEOMZMFROMTEXT
Returns a geometry object that corresponds to the Well Known Text (WKT) in s. The SRID can optionally be specified. It is ‑1 by default. This function only supports geometries that contain both Z and M coordinates.
Result type: geometry
Examples:
SELECT ASTEXT(GEOMZMFROMTEXT('MULTIPOINT ZM(0 1 1 5, 1 2 2 5, 3 5 2 5, 8 13 1 5)'));
--------------------------------
col1
--------------------------------
MULTIPOINT ZM (0 1 1 5, 1 2 2 5, 3 5 2 5, 8 13 1 5)
--------------------------------
SRID of point when it is not specified:
SELECT SRID(GEOMZMFROMTEXT('POINT Z(1 2 2 1)'));
-------------
col1
-------------
-1
-------------
SRID of point when it is specified:
SELECT SRID(GEOMZMFROMTEXT('POINT ZM(1 2 2 1)', 4955));
-------------
col1
-------------
4955
-------------
GeometryZMFromWKB
GEOMETRYZFROMWKB(b binary [, srid integer])
Last modified date: 01/30/2023