ST_MPointFromWKB function
The ST_MPointFromWKB function takes a well-known binary (WKB) format of a multipoint and, optionally, a spatial reference system identifier as input parameters and returns the corresponding multipoint.
If the specified WKB format is null, then null is returned.
The recommended function for achieving the same result is the ST_MultiPoint function. It is recommended because of its flexibility: ST_MultiPoint takes additional forms of input as well as the well-known binary format.
Syntax
Parameters
- wkb
- A value of type VARBINARY or BLOB(2G) that contains the well-known binary format of the resulting multipoint.
- srs_id
- A value of type INTEGER that identifies the spatial reference
system for the resulting multipoint.
If the srs_id parameter is omitted, the spatial reference system with the numeric identifier 4326 is used.
If the specified 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_MultiPoint
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.
This example illustrates how ST_MPointFromWKB can be used to create a multipoint from its well-known binary format. The geometry is a multipoint in spatial reference system 1. In this example, the multipoint gets stored with ID = 10 in the GEOMETRY column of the SAMPLE_MPOINTS table, and then the WKB column is updated with its well-known binary format (using the ST_AsBinary function). Finally, the ST_MPointFromWKB function is used to return the multipoint from the WKB column. The X and Y coordinates for this geometry are: (44, 14) (35, 16) (24, 13).
CREATE TABLE sample_mpoints (id INTEGER, geometry ST_MultiPoint,
wkb varbinary(32000))
INSERT INTO sample_mpoints
VALUES (10, ST_MultiPoint ('multipoint ( 4 14, 35 16, 24 13)', 1))
UPDATE sample_mpoints AS temporary_correlated
SET wkb = ST_AsBinary( geometry )
WHERE id = temporary_correlated.id
SELECT id, CAST( ST_AsText( ST_MLineFromWKB (wkb, 1)) AS VARCHAR(100)) MULTIPOINT
FROM sample_mpoints
WHERE id = 10
ID MULTIPOINT
--- -------------------------------------------------------------------------
10 MULTIPOINT (4.000000 14.000000, 35.000000 16.000000, 24.000000 13.000000)