ArcGIS Server Banner

ST_MPolyFromShape

ST_MPolyFromShape

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback

NOTE: Spatial type for PostgreSQL only

Definition

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

Syntax

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 to 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 st_geometry, shape bytea);

INSERT INTO mpolys VALUES (
1,
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 = 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, st_astext (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 )))

See Also

  • An overview of SQL functions used with ST_Geometry types