ST_LinestringFromWKB

更新时间:
复制 MD 格式

Constructs a LineString geometry from a Well-Known Binary (WKB) representation and an optional spatial reference identifier (SRID).

Syntax

geometry ST_LinestringFromWKB(bytea WKB);
geometry ST_LinestringFromWKB(bytea WKB, integer srid);

Parameters

ParameterDescription
WKBThe WKB representation of the geometry.
sridThe SRID to assign to the resulting LineString. Defaults to 0 if not specified.

Usage notes

  • If the WKB does not represent a LineString, the function returns NULL.

  • If you are certain the WKB represents a LineString, use ST_GeomFromWKB instead, which constructs the geometry more efficiently. ST_LineFromWKB is equivalent to this function.

Examples

The following example constructs a LineString from a WKB hex string and returns the WKT representation:

SELECT ST_AsText(ST_LineFromWKB(E'\\x010200000002000000000000000000f03f000000000000004000000000000008400000000000001040'));
      st_astext
---------------------
 LINESTRING(1 2,3 4)
(1 row)