ArcGIS Server Banner

ST_MPolyFromWKB

ST_MPolyFromWKB

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Note: This topic was updated for 9.3.1.

Definition

ST_MPolyFromWKB takes a well-known binary (WKB) representation of type ST_MultiPolygon and a spatial reference ID to return an ST_MultiPolygon.

Syntax

Oracle

sde.st_mpolyfromwkb (wkb blob, srid integer)

PostgreSQL

st_mpolyfromwkb (wkb bytea, srid integer)

Return type

ST_MultiPolygon

Example

In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display. This example illustrates how ST_MPolyFromWKB can be used to create a multipolygon from its well-known binary representation. The geometry is a multipolygon in spatial reference system 1. In this example, the multipolygon is stored with ID = 10 in the geometry column of the sample_mpolys table, then the wkb column is updated with its well-known binary representation (using the ST_AsBinary function). Finally, the ST_MPolyFromWKB function is used to return the multipolygon from the wkb column. The x- and y-coordinates for this geometry are v Polygon 1: (1, 72) (4, 79) (5, 76) (1, 72), v Polygon 2: (10, 20) (10, 40) (30, 41)(10, 20), and v Polygon 3: (9, 43) (7, 44) (6, 47) (9, 43). The sample_mpolys table has a geometry column, where the multipolygon is stored, and a wkb column, where the multipolygon's WKB representation is stored.

Oracle

CREATE TABLE sample_mpolys (id integer, geometry sde.st_geometry, wkb blob);

INSERT INTO sample_mpolys VALUES (
10,
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 sample_mpolys
SET wkb = sde.st_asbinary (geometry)
WHERE id = 10;

PostgreSQL

CREATE TABLE sample_mpolys (id integer, geometry st_geometry, wkb bytea);

INSERT INTO sample_mpolys VALUES (
10,
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 sample_mpolys
SET wkb = st_asbinary (geometry)
WHERE id = 10;

In the following SELECT statement, the ST_MPolyFromWKB function is used to retrieve the multipolygon from the wkb column.

Oracle

SELECT id, sde.st_astext (sde.st_mpolyfromwkb (wkb,0)) MULTIPOLYGON
FROM sample_mpolys
WHERE id = 10;

ID   MULTIPOLYGON

10   MULTIPOLYGON (((10.00000000 20.00000000, 30.00000000 41.00000000, 10.00000000 40.00000000, 10.00000000 20.00000000)), (1.00000000 72.00000000, 5.00000000 76.00000000, 4.00000000 79.0000000, 1.00000000 72,00000000)), (9.00000000 43.00000000, 6.00000000 47.00000000, 7.00000000 44.00000000, 9.00000000 43.00000000 )))

PostgreSQL

SELECT id, st_astext (st_mpolyfromwkb (wkb,0)) AS MULTIPOLYGON
FROM sample_mpolys
WHERE id = 10;

id   multipolygon

10   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