ST_Point function

The ST_Point function constructs a point from coordinate information or a resulting point of a representation.

ST_Point constructs a point from one of the following sets of input:
  • X and Y coordinates only
  • X, Y, and Z coordinates
  • X, Y, Z, and M coordinates
  • A well-known text representation
  • A well-known binary representation
  • A shape representation
  • A representation in the geography markup language (GML)
An optional spatial reference system identifier can be specified to indicate the spatial reference system that the resulting point is in.

If the point is constructed from coordinates, and if the X or Y coordinate is null, then an exception condition is raised (SQLSTATE 38SUP). If the Z or M coordinate is null, then the resulting point will not have a Z or M coordinate, respectively. If the point is constructed from its well-known text representation, its well-known binary representation, its shape representation, or its GML representation, and if the representation is null, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_Point(coordinateswktwkbgmlshape,srs_id)
coordinates
Read syntax diagramSkip visual syntax diagramx_coordinate,y_coordinate ,z_coordinate,m_coordinate

Parameters

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

If the srs_id parameter is omitted, 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 exception condition is raised (SQLSTATE 38SU1).

x_coordinate
A value of type DOUBLE that specifies the X coordinate for the resulting point.
y_coordinate
A value of type DOUBLE that specifies the Y coordinate for the resulting point.
z_coordinate
A value of type DOUBLE that specifies the Z coordinate for the resulting point.

If the z_coordinate parameter is omitted, the resulting point will not have a Z coordinate. The result of ST_Is3D is 0 (zero) for such a point.

m_coordinate
A value of type DOUBLE that specifies the M coordinate for the resulting point.

If the m_coordinate parameter is omitted, the resulting point will not have a measure. The result of ST_IsMeasured is 0 (zero) for such a point.

Return type

db2gse.ST_Point

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.

Example 1
This example illustrates how ST_Point can be used to create and insert points. The first point is created using a set of X and Y coordinates. The second point is created using its well-known text representation. Both points are geometries in spatial reference system 1.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_points (id INTEGER, geometry ST_Point)

INSERT INTO sample_points
  VALUES (1100, ST_Point (10, 20, 1) )

INSERT INTO sample_points
  VALUES (1101, ST_Point ('point (30 40)', 1) )
The following SELECT statement returns the points that were recorded in the table:

SELECT id, CAST( ST_AsText( geometry ) AS VARCHAR(90)) POINTS
  FROM sample_points
Results:

ID         POINTS
---------- ------------------------------------
      1110 POINT ( 10.00000000 20.00000000)
      1101 POINT ( 30.00000000 40.00000000)

Example 2
This example inserts a record into the SAMPLE_POINTS table with ID 1103 and a point value with an X coordinate of 120, a Y coordinate of 358, an M coordinate of 34, but no Z coordinate.

INSERT INTO SAMPLE_POINTS(ID, GEOMETRY) 
 VALUES(1103, db2gse.ST_Point(120, 358, CAST(NULL AS DOUBLE), 34, 1))
 SELECT id, CAST( ST_AsText( geometry ) AS VARCHAR(90) ) POINTS
 FROM sample_points
Results:

ID         POINTS
 ---------- ------------------------------------------------
       1103 POINT M ( 120.0000000 358.0000000 34.00000000)
Example 3
This example inserts a row into the SAMPLE_POINTS table with ID 1104 and a point value with an X coordinate of 1003, a Y coordinate of 9876, a Z coordinate of 20, and in spatial reference system 0, using the geography markup language for its representation.

INSERT INTO SAMPLE_POINTS(ID, GEOMETRY)
 VALUES(1104, db2gse.ST_Point('<gml:Point><gml:coord>
    <gml:x>1003</gml:X><gml:Y>9876</gml:Y><gml:Z>20</gml:Z>
    </gml:coord></gml:Point>', 1))
 SELECT id, CAST( ST_AsText( geometry ) AS VARCHAR(90) ) POINTS
 FROM sample_points
Results:

ID         POINTS
 ---------- ----------------------------------------------------
       1104 POINT Z ( 1003.000000 9876.000000 20.00000000)