ST_AsShape
St_AsShape takes a geometry as an input parameter and returns its ESRI shape representation.
If the given geometry is null, then null is returned.
Syntax
Parameter
- geometry
- A value of one of the seven distinct spatial data types to be converted to the corresponding ESRI shape representation.
Return type
BLOB(4M)
Example
The following code fragment illustrates
how to use the ST_AsShape function to convert the points in the geometry
column of the SAMPLE_POINTS table into shape binary representation
in the shape BLOB column. This example populates the shape column
from the geometry column. The shape binary representation is used
to display the geometries in geobrowsers, which require geometries
to comply with the ESRI shapefile format, or to construct the geometries
for the *.SHP file of the shape file.
SET CURRENT PATH = CURRENT PATH, db2gse;
CREATE TABLE SAMPLE_POINTS (id integer, geometry ST_POINT, shape BLOB(32K));
INSERT INTO SAMPLE_POINTS (id, geometry)
VALUES
(1100, ST_Point(10, 20, 1));
INSERT INTO sample_points(id, shape)
VALUES (2222,
(SELECT ST_AsShape(geometry)
FROM sample_points
WHERE id = 1100));
SELECT id, HEX(substr(ST_AsShape(geometry), 1, 20)) AS shape
FROM sample_points
WHERE id = 1100;
Returns:
ID SHAPE
------ -------------------------------------------
1100 0100000000000000000024400000000000003440