ST_GeomFromShape constructs a geometry from an ESRI shape.
st_geomfromshape (esri_shape bytea, srid integer)
The following example inserts a record into the geoshape table with an ID and two geometry columns.
CREATE TABLE geoshape (id integer, g1 st_geometry, g2 bytea);
The INSERT statements insert the data into the columns of the geoshape table. The SELECT statement at the end ensures data was inserted into the g1 column.
INSERT INTO geoshape (id, g1) VALUES (
1,
st_geometry ('point (10 10)', 0)
);
INSERT INTO geoshape (id, g1) VALUES (
2,
st_geometry ('linestring (10 10, 20 20, 30 30)', 0)
);
UPDATE geoshape
SET g2 = st_asshape (g1)
WHERE id = 1;
UPDATE geoshape
SET g2 = st_asshape (g1)
WHERE id = 2;
SELECT id, st_astext (st_geomfromshape (g2, 0))
FROM geoshape;
id st_astext
1 POINT ( 10 10)
2 LINESTRING ( 10 10, 20. 20, 3 30)