ArcGIS Server Banner

ST_PolyFromWKB

ST_PolyFromWKB

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

Definition

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

Syntax

Oracle

sde.st_polyfromwkb (wkb blob, srid integer)

PostgreSQL

st_polyfromwkb (wkb bytea, srid integer)

Return type

ST_Polygon

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_PolyFromWKB can be used to create a polygon from its well-known binary representation. The geometry is a polygon in spatial reference system 1. In this example, the polygon is stored with ID = 1115 in the geometry column of the sample_polys table, and then the wkb column is updated with its WKB representation (using the ST_AsBinary function). Finally, the ST_PolyFromWKB function is used to return the multipolygon from the wkb column. The x- and y-coordinates for this geometry are (50, 20) (50, 40) (70, 30). The sample_polys table has a geometry column, where the polygon is stored, and a wkb column, where the polygon's WKB representation is stored.

Oracle

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

INSERT INTO sample_polys (id, geometry) VALUES (
1115,
sde.st_polyfromtext ('polygon ((10.01 20.03, 10.52 40.11, 30.29 41.56,
31.78 10.74, 10.01 20.03))', 0)
);

UPDATE sample_polys
SET wkb = sde.st_asbinary (geometry)
WHERE id = 1115;

PostgreSQL

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

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

In the following SELECT statement, the ST_PointFromWKB function is used to retrieve the points from the wkb column.

Oracle

SELECT id, sde.st_astext (sde.st_polyfromwkb (wkb, 0)) POLYS
FROM sample_polys;

ID    	POLYS

1115    POLYGON (10.01000000 20.03000000, 31.78000000 10.74000000, 30.29000000 41.56000000, 10.52000000 40.11000000, 10.01000000 20.03000000)

PostgreSQL

SELECT id, st_astext (st_polyfromwkb (wkb, 0)) AS POLYS
FROM sample_polys;

id    polys

1115    POLYGON (10.01000000 20.03000000, 31.78000000 10.74000000, 30.29000000 41.56000000, 10.52000000 40.11000000, 10.01000000 20.03000000)

See Also

  • An overview of SQL functions used with ST_Geometry types