ST_LineFromWKB

ST_LineFromWKB takes a well-known binary representation of a linestring and a spatial reference system identifier as input parameters and returns the corresponding linestring.

If the given well-known binary representation is null, then null is returned.

The preferred version for this functionality is ST_LineString.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_LineFromWKB(+wkb+ ,srs_id)

Parameter

wkb
A value of type BLOB(4M) that contains the well-known binary representation of the resulting linestring.
srs_id
A value of type INTEGER that identifies the spatial reference system for the resulting linestring.

Return type

db2gse.ST_LineString

Example

In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.

The following code uses the ST_LineFromWKB function to create and insert a line from a well-known binary representation. The row is inserted into the SAMPLE_LINES table with an ID and a line in spatial reference system 1 in WKB representation.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 

CREATE TABLE sample_lines(id SMALLINT, geometry ST_LineString, wkb BLOB(32k))

INSERT INTO sample_lines(id, geometry)
VALUES
    (1901, ST_LineString('linestring(850 250, 850 850)', 1) ),
INSERT INTO sample_lines(id, geometry)
VALUES
    (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)) AS varchar(90)) line
FROM   sample_lines

Results:

ID     LINE                                                                         
------ --------------------------------------------------------------------
  1901 LINESTRING ( 850.00000000 250.00000000, 850.00000000 850.00000000)
           
  1902 LINESTRING ( 33.00000000 2.00000000, 34.00000000 3.00000000, 
35.00000000 6.00000000)