ST_PolyFromShape

RemarqueRemarque :

ST_Geometry in PostgreSQL only

Definition

ST_PolyFromShape takes an ESRI multipolygon shape and a spatial reference ID and returns a polygon.

Syntax

sde.st_polyfromshape (esri_shape bytea, srid integer)

Return type

ST_Polygon

Example

This example illustrates how ST_PolyFromShape can be used to create a polygon from an ESRI shape representation. In this example, the polygon is stored in the geometry column of the polys table, then the shape column is updated with its ESRI shape representation (using the ST_AsShape function). Finally, the ST_PolyFromShape function is used to return the multipolygon from the shape column. The x- and y-coordinates for this geometry are (50, 20) (50, 40) (70, 30). The polys table has a geometry column, where the polygon is stored; a shape column, where the polygon's ESRI shape representation is stored; and an id column to uniquely identify each record.

CREATE TABLE polys (id integer unique, geometry sde.st_geometry, shape bytea);

INSERT INTO polys VALUES (
111,
sde.st_polygon ('polygon  ((10.01 20.03, 10.52 40.11, 30.29 41.56,
31.78 10.74, 10.01 20.03))', 0)
);

UPDATE polys
SET shape = sde.st_asshape (geometry)
WHERE id = 111;
SELECT id, sde.st_astext (sde.st_polyfromshape (shape, 0))
AS polygon
FROM polys;

id     polygon
111    POLYGON (10.01000000 20.03000000, 31.78000000 10.74000000, 
30.29000000 41.56000000, 10.52000000 40.11000000, 10.01000000 20.03000000)

2/28/2012