ST_AsEWKB
Name
ST_AsEWKB — Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.
Synopsis
bytea
ST_AsEWKB
(
geometry
g1
)
;
bytea
ST_AsEWKB
(
geometry
g1
, text
NDR_or_XDR
)
;
Description
Returns the Well-Known Binary representation of the geometry with SRID metadata. There are 2 variants of the function. The first variant takes no endian encoding parameter and defaults to little endian. The second variant takes a second argument denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.
This is useful in binary cursors to pull data out of the database without converting it to a string representation.
The WKB spec does not include the SRID. To get the OGC WKB format use ST_AsBinary |
ST_AsEWKB is the reverse of ST_GeomFromEWKB. Use ST_GeomFromEWKB to convert to a postgis geometry from ST_AsEWKB representation. |
Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.
This function supports 3d and will not drop the z-index.
This method supports Circular Strings and Curves
This function supports Polyhedral surfaces.
This function supports Triangles and Triangulated Irregular Network Surfaces (TIN).
Examples
SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326)); st_asewkb -------------------------------- \001\003\000\000 \346\020\000\000\001\000 \000\000\005\000\000\000\000 \000\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\000\000\000 \000\000\360?\000\000\000\000\000\000\360? \000\000\000\000\000\000\360?\000\000\000\000\000 \000\360?\000\000\000\000\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\000\000\000\000\000\000 (1 row)
SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR'); st_asewkb -------------------------------- \000 \000\000\003\000\000\020\346\000\000\000\001\000\000\000\005\000\000\000\000\ 000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000? \360\000\000\000\000\000\000?\360\000\000\000\000\000\000?\360\000\000\000\000 \000\000?\360\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\000\000\000\000\000\000