ST_AsShape function
The St_AsShape function takes a geometry as an input parameter and returns its ESRI shape format.
If the specified geometry is null, then null is returned.
Syntax
Parameter
- geometry
- A value of type ST_Geometry or one of its subtypes to be converted to the corresponding ESRI shape format.
Return type
BLOB(2G)
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 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.
CREATE TABLE SAMPLE_POINTS (id integer, geometry ST_POINT, shape varbinary(32000))
;
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))
;
UPDATE sample_points SET geometry = st_point(shape, 1) WHERE id = 2222
;
SELECT id, substr(ST_AsShape(geometry), 1, 20) AS shape
FROM sample_points
;
Returns:
ID SHAPE
----------- -------------------------------------------
1100 x'0100000000000000000024400000000000003440'
2222 x'0100000000000000000024400000000000003440'
SELECT id, substr(ST_AsText(geometry), 1, 50) AS shape FROM sample_points
;
Returns:
ID SHAPE
----------- --------------------------------------------------
1100 POINT (10.000000 20.000000)
2222 POINT (10.000000 20.000000)