ST_AsBinary — Returns the well-known binary (WKB) representation of a Geometry object.
bytea ST_AsBinary(
bytea
Geometry)
;
bytea ST_AsBinary(
bytea
Geometry, varchar byteorder
XDR/NDR)
;
Returns the well-known binary representation of a Geometry object.
The byteorder parameter may be either NDR or XDR. If no encoding is specified, the default value is NDR.
NDR indicates Network Data Representation, also known as little-endian encoding.
XDR represents External Data Representation, also known as big-endian encoding.
The WKB format, doesn't store the SRID. For that, use EWKB format |
The reverse function is ST_GeomFromEWKB |
2D | 3D | M |
---|---|---|
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
2.1.1.1 | 7.2.9.1 | 7.2.8.1 | 5.1.37 |
--Get the WKB SELECT ST_AsBinary(ST_GeomFromText('POINT(5 5 10)',25830)); st_asbinary ----------------------------------------------------------------------------------- \001\001\000\000\200\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000$@ (1 row) SELECT ST_AsBinary(ST_GeomFromText('POINT(5 5 10)'),'XDR'); st_asbinary ---------------------------------------------------------------------------------------------------------- \000\200\000\000\001@\024\000\000\000\000\000\000@\024\000\000\000\000\000\000@$\000\000\000\000\000\000 (1 row) SELECT ST_AsBinary(ST_GeomFromText('POINT(5 5 10)'),'NDR'); st_asbinary ---------------------------------------------------------------------------------------------------------- \001\001\000\000\200\000\000\000\000\000\000\024@\000\000\000\000\000\000\024@\000\000\000\000\000\000$@ (1 row)
SELECT ST_AsBinary(ST_GeomFromText('POINT(1 1 1)',25830)); 0101000080000000000000f03f000000000000f03f000000000000f03f SELECT ST_AsBinary(ST_GeomFromText('POINT(1 1 1)'),'XDR'); 00800000013ff00000000000003ff00000000000003ff0000000000000 SELECT ST_AsBinary(ST_GeomFromText('POINT(1 1 1)'),'NDR'); 0101000080000000000000f03f000000000000f03f000000000000f03f