Definition
ST_PolyFromWKB takes a well-known binary (WKB) representation and a spatial reference ID and returns an ST_Polygon.
Syntax
Oracle
sde.st_polyfromwkb (wkb blob, srid integer)
PostgreSQL
sde.st_polyfromwkb (wkb bytea, srid integer)
SQLite
st_polyfromwkb (wkb blob, srid int32)
Return type
ST_Polygon
Example
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 4326. 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 sample_polys table has a geometry column, where the polygon is stored, and a wkb column, where the polygon's WKB representation is stored.
In the SELECT statement, the ST_PointFromWKB function is used to retrieve the points from the WKB column.
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))', 4326)
);
UPDATE SAMPLE_POLYS
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 1115;
SELECT id, sde.st_astext (sde.st_polyfromwkb (wkb, 4326)) 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
CREATE TABLE sample_polys (
 id integer,
 geometry sde.st_geometry,
 wkb bytea
);
INSERT INTO sample_polys (id, geometry) VALUES (
 1115,
 sde.st_polygon ('polygon  ((10.01 20.03, 10.52 40.11, 30.29 41.56, 31.78 10.74, 10.01 20.03))', 4326)
);
UPDATE sample_polys
 SET wkb = sde.st_asbinary (geometry)
 WHERE id = 1115;
SELECT id, sde.st_astext (sde.st_polyfromwkb (wkb, 4326)) 
 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)
SQLite
CREATE TABLE sample_polys(
 id integer,
 wkb blob
);
SELECT AddGeometryColumn(
 NULL,
 'sample_polys',
 'geometry',
 4326,
 'polygon',
 'xy',
 'null'
);
INSERT INTO sample_polys (id, geometry) VALUES (
 1115,
 st_polyfromtext ('polygon ((10.01 20.03, 10.52 40.11, 30.29 41.56, 31.78 10.74, 10.01 20.03))', 4326)
);
UPDATE sample_polys
 SET wkb = st_asbinary (geometry)
 WHERE id = 1115;
SELECT id, st_astext (st_polyfromwkb (wkb, 4326)) 
 AS "polygons"
 FROM sample_polys;
id    polygons
1115    POLYGON (10.01000000 20.03000000, 31.78000000 10.74000000, 30.29000000 41.56000000, 10.52000000 40.11000000, 10.01000000 20.03000000)