ST_GeomCollFromWKB function

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

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

The preferred version for this functionality is ST_GeomCollection.

Syntax

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

Parameter

wkb
A value of type BLOB(2G) that contains the well-known binary representation of the resulting geometry collection.
srs_id
A value of type INTEGER that identifies the spatial reference system for the resulting geometry collection.

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 error is returned (SQLSTATE 38SU1).

Return type

db2gse.ST_GeomCollection

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.

The following code illustrates how the ST_GeomCollFromWKB function can be used to create and query the coordinates of a geometry collection in a well-known binary representation. The rows are inserted into the SAMPLE_GEOMCOLLECTION table with IDs 4021 and 4022 and geometry collections in spatial reference system 1.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 

CREATE TABLE sample_geomcollections(id INTEGER, 
  geometry ST_GEOMCOLLECTION, wkb BLOB(32k))

INSERT INTO sample_geomcollections(id, geometry)
VALUES
  (4021, ST_GeomCollFromTxt('multipoint(1 2, 4 3, 5 6)', 1)),
  (4022, ST_GeomCollFromTxt('multilinestring(
                           (33 2, 34 3, 35 6),
                           (28 4, 29 5, 31 8, 43 12))', 1))

UPDATE sample_geomcollections AS temp_correlated
SET    wkb = geometry..ST_AsBinary
WHERE  id = temp_correlated.id
 
SELECT id, cast(ST_GeomCollFromWKB(wkb)..ST_AsText
   AS varchar(190)) AS GeomCollection
FROM   sample_geomcollections

Results:

ID          GEOMCOLLECTION
----------- -----------------------------------------------------
       4021 MULTIPOINT ( 1.00000000 2.00000000, 4.00000000 
  3.00000000, 5.00000000 6.00000000)                
                                                           
       4022 MULTILINESTRING (( 33.00000000 2.00000000,
 34.00000000 3.00000000, 35.00000000 6.00000000),( 28.00000000
 4.00000000, 29.00000000 5.00000000, 31.00000000 8.00000000, 
 43.00000000 12.00000000))