ST_LineFromWKB function
The ST_LineFromWKB function takes a well-known binary (WKB) representation of a linestring and, optionally, a spatial reference system identifier as input parameters and returns the corresponding linestring.
If the specified WKB format is null, then null is returned.
The preferred version for this functionality is ST_LineString.
Syntax
Parameter
- wkb
- A value of type VARBINARY or BLOB(2G) that contains the well-known binary format of the resulting linestring.
- srs_id
- A value of type INTEGER that identifies the spatial reference
system for the resulting linestring.
If the srs_id parameter is omitted, the spatial reference system with the numeric identifier 4326 is used.
If srs_id does not identify a spatial reference system listed in the catalog view SYSGEO.ST_SPATIAL_REFERENCE_SYSTEMS, then an error is returned (SQLSTATE 38SU1).
Return type
ST_LineString
Example
In the following examples, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.
CREATE TABLE sample_lines(id SMALLINT, geometry ST_LineString, wkb varbinary(32000))
INSERT INTO sample_lines(id, geometry)
VALUES
(1901, ST_LineString('linestring(850 250, 850 850)', 1) ),
(1902, ST_LineString('linestring(33 2, 34 3, 35 6)', 1) )
UPDATE sample_lines AS temp_correlated
SET wkb = ST_AsBinary(geometry)
WHERE id = temp_correlated.id
SELECT id, cast(ST_AsText(ST_LineFromWKB(wkb, 1)) AS varchar(90)) AS line
FROM sample_lines
Results:
ID LINE
------ -----------------------------------------------------------------------
1901 LINESTRING (850.000000 250.000000, 850.000000 850.000000)
1902 LINESTRING (33.000000 2.000000, 34.000000 3.000000, 35.000000 6.000000)