ST_GeomFromWKB

Name

ST_GeomFromWKB — Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional SRID.

Synopsis

geometry ST_GeomFromWKB ( bytea geom ) ;

geometry ST_GeomFromWKB ( bytea geom , integer srid ) ;

Description

The ST_GeomFromWKB function, takes a well-known binary representation of a geometry and a Spatial Reference System ID ( SRID ) and creates an instance of the appropriate geometry type. This function plays the role of the Geometry Factory in SQL. This is an alternate name for ST_WKBToSQL.

If SRID is not specified, it defaults to 0 (Unknown).

This method implements the OGC Simple Features Implementation Specification for SQL 1.1.

s3.2.7.2 - the optional SRID is from the conformance suite

This method implements the SQL/MM specification.

SQL-MM 3: 5.1.41

This method supports Circular Strings and Curves.

Examples

--Although bytea rep contains single \, these need to be escaped when inserting into a table
		-- unless standard_conforming_strings is set to on.
SELECT ST_AsEWKT(
ST_GeomFromWKB(E'\\001\\002\\000\\000\\000\\002\\000\\000\\000\\037\\205\\353Q\\270~\\\\\\300\\323Mb\\020X\\231C@\\020X9\\264\\310~\\\\\\300)\\\\\\217\\302\\365\\230C@',4326)
);
					  st_asewkt
------------------------------------------------------
 SRID=4326;LINESTRING(-113.98 39.198,-113.981 39.195)
(1 row)

SELECT
  ST_AsText(
	ST_GeomFromWKB(
	  ST_AsEWKB('POINT(2 5)'::geometry)
	)
  );
 st_astext
------------
 POINT(2 5)
(1 row)