ST_PointFromWKB function

The ST_PointFromWKB function takes a well-known binary representation of a point and, optionally, a spatial reference system identifier as input parameters and returns the corresponding point.

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

The recommended function for achieving the same result is the ST_Point function. It is recommended because of its flexibility: ST_Point takes additional forms of input as well as the well-known binary representation.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_PointFromWKB(wkb ,srs_id )

Parameters

wkb
A value of type BLOB(2G) that contains the well-known binary 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 implicitly.

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).

Return type

db2gse.ST_Point

Example

This example illustrates how ST_PointFromWKB can be used to create a point from its well-known binary representation. The geometries are points in spatial reference system 1. In this example, the points get stored in the GEOMETRY column of the SAMPLE_POLYS table, and then the WKB column is updated with their well-known binary representations (using the ST_AsBinary function). Finally, the ST_PointFromWKB function is used to return the points from the WKB column.

The SAMPLE_POINTS table has a GEOMETRY column, where the points are stored, and a WKB column, where the points' well-known binary representations are stored.

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

INSERT INTO sample_points
  VALUES (10, ST_Point ('point (44 14)', 1) ),
  VALUES (11, ST_Point ('point (24 13)', 1))

UPDATE sample_points AS temporary_correlated
  SET wkb = ST_AsBinary( geometry )
  WHERE id = temporary_correlated.id

In the following SELECT statement, the ST_PointFromWKB function is used to retrieve the points from the WKB column.

SELECT id, CAST( ST_AsText( ST_PolyFromWKB (wkb) ) AS VARCHAR(35) ) POINTS
  FROM sample_points
Results:

ID         POINTS
---------- -----------------------------------
        10 POINT ( 44.00000000 14.00000000)
        11 POINT ( 24.00000000 13.00000000)