ST_PointFromWKB function

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

If the specified WKB format 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 format.

Syntax

Read syntax diagramSkip visual syntax diagramST_PointFromWKB(wkb ,srs_id )

Parameters

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

If srs_id does not identify a spatial reference system listed in the catalog view SYSGEO.ST_SPATIAL_REFERENCE_SYSTEMS, then an exception condition is raised (SQLSTATE 38SU1).

Return type

ST_Point

Example

This example illustrates how ST_PointFromWKB can be used to create a point from its well-known binary format. 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 formats (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 formats are stored.

CREATE TABLE sample_points (id INTEGER, geometry ST_Point, wkb VARBINARY(32000)))

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, 1) ) AS VARCHAR(35) ) POINTS
  FROM sample_points
Results:

ID          POINTS
----------- -----------------------------------
         10 POINT (44.000000 14.000000)
         11 POINT (24.000000 13.000000)