PostGIS

ST_AsEWKB

Prev

7.9.2. Well-Known Binary (WKB)

Next

Name

ST_AsEWKB — Return the Extended Well-Known Binary (EWKB) 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 Extended Well-Known Binary (EWKB) representation of the geometry with SRID metadata. The first function variant defaults to encoding using server machine endian. The second function variant takes a text argument specifying the endian encoding, either little-endian ('NDR') or big-endian ('XDR').

WKB format is useful to read geometry data from the database and maintaining full numeric precision. This avoids the precision rounding that can happen with text formats such as WKT.

To perform the inverse conversion of EWKB to PostGIS geometry use ST_GeomFromEWKB.

Note

To get the OGC/ISO WKB format use ST_AsBinary. Note that OGC/ISO WKB format does not include the SRID.

Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.

check This function supports 3d and will not drop the z-index.

check This method supports Circular Strings and Curves.

check This function supports Polyhedral surfaces.

check 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
--------------------------------
\x0103000020e610000001000000050000000000000000000000000000000000000000000000000000
00000000000000f03f000000000000f03f000000000000f03f000000000000f03f00000000000000
0000000000000000000000000000000000
            SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR');
           st_asewkb
--------------------------------
\x0020000003000010e600000001000000050000000000000000000000000000000000000000000000
003ff00000000000003ff00000000000003ff00000000000003ff000000000000000000000000000
0000000000000000000000000000000000

See Also

Prev

Up

Next

ST_AsBinary

Home

ST_AsHEXEWKB