ST_MPolyFromShape

メモメモ:

ST_Geometry in PostgreSQL only

Definition

ST_MPolyFromShape takes an ESRI Multipolygon shape and a spatial reference ID and returns an ST_MultiPolygon.

Syntax

sde.st_mpolyfromshape (esri_shape bytea, srid integer)

Return type

ST_MultiPolygon

Example

This example illustrates how ST_MPolyFromShape can be used to create a multipolygon from an ESRI multipolygon shape.

In this example, a table with an st_geometry column is created. A record is inserted into the table to store a multipolygon. The record is then updated using a shape representation (using the ST_AsShape function).

ST_MPointFromShape function is then used to return the multipoint information from the shape column.

The mpolys table has a geometry column, where the multipoint is stored, and a shape column, where the multipoint's ESRI shape representation is stored.

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

INSERT INTO mpolys VALUES (
1,
sde.st_multipolygon ('multipolygon (((1 72, 4 79, 5 76, 1 72), (10 20, 10 40, 30 41, 10 20), (9 43, 7 44, 6 47, 9 43)))', 0)
);

UPDATE mpolys
SET shape = sde.st_asshape (geometry)
WHERE id = 1;

In the following SELECT statement, the ST_MPolyFromShape function is used to retrieve the multipolygon from the shape column.

SELECT id, sde.st_astext (sde.st_mpolyfromshape (shape)) 
AS MULTIPOLYGON
FROM mpolys
WHERE id = 1;

id   multipolygon

1   MULTIPOLYGON (((10 20, 30 41, 10 40, 10 20)),
 (1 72, 5 76, 4 79, 1 72)), (9 43, 6 47, 7 44, 9 43 )))

3/6/2012