ST_LineString function

The ST_LineString function constructs a linestring from given input.

The inputs can be given in one of the following formats:
  • A well-known text representation
  • A well-known binary representation
  • An ESRI shape representation
  • A representation in the geography markup language (GML)
A spatial reference system identifier can be provided optionally to identify the spatial reference system that the resulting linestring is in.

If the well-known text representation, the well-known binary representation, the ESRI shape representation, or the GML representation is null, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_LineString(wktwkbshapegml,srs_id)

Parameter

wkt
A value of type CLOB(2G) that contains the well-known text representation of the resulting polygon.
wkb
A value of type BLOB(2G) that contains the well-known binary representation of the resulting polygon.
shape
A value of type BLOB(2G) that represents the ESRI shape representation of the resulting polygon.
gml
A value of type CLOB(2G) that represents the resulting polygon using the geography markup language (GML).
srs_id
A value of type INTEGER that identifies the spatial reference system for the resulting polygon.

If the srs_id parameter is omitted, then the spatial reference system with the numeric identifier 0 (zero) is used.

If srs_id does not identify a spatial reference system listed in the catalog view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS, then an error is returned (SQLSTATE 38SU1).

Return type

db2gse.ST_LineString

Examples

The following code uses the ST_LineString function to create and insert a line from a well-known text (WKT) line representation or from a well-known binary (WKB) representation.

The following example inserts a row into the SAMPLE_LINES table with an ID and line in spatial reference system 1 in WKT and GML representation

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 
 
CREATE TABLE sample_lines(id SMALLINT, geometry ST_LineString)
 
INSERT INTO sample_lines(id, geometry)
VALUES
    (1110, ST_LineString('linestring(850 250, 850 850)', 1) ),
    (1111, ST_LineString('<gml:LineString srsName=";EPSG:4269";><gml:coord>
                          <gml:X>90</gml:X><gml:Y>90</gml:Y>
                          </gml:coord><gml:coord><gml:X>100</gml:X>
                          <gml:Y>100</gml:Y></gml:coord>
                          </gml:LineString>', 1) )

SELECT id, cast(geometry..ST_AsText AS varchar(75)) AS linestring
FROM   sample_lines 

Results:

ID     LINESTRING
------ ------------------------------------------------------------------
  1110 LINESTRING ( 850.00000000 250.00000000, 850.00000000 850.00000000)
  1111 LINESTRING ( 90.00000000 90.00000000, 100.00000000 100.00000000)