[postgis-users] from EWKB to WKB

Mike Toews mwtoews at gmail.com
Thu Apr 25 05:32:13 PDT 2013


On 26 April 2013 00:15, Worth Lutz <wal3 at mindspring.com> wrote:
> SELECT ST_AsBinary( ST_GeomFromEWKB(‘01 01000020 04000000
> 000000000000F03F0000000000000000’));
>
> Just a guess!  I haven’t tried it.

It seems I missed the "B", so yes ST_AsBinary is the correct function
to convert to WKB.

http://postgis.org/docs/ST_AsBinary.html

postgis=# \x
Expanded display is on.
postgis=# SET bytea_output='hex';
SET
postgis=# SELECT ST_AsEWKB(g), ST_AsBinary(g)
postgis-# FROM (SELECT 'SRID=4;POINT(1 0)'::geometry AS g) AS f;
-[ RECORD 1 ]-----------------------------------------------------
st_asewkb   | \x010100002004000000000000000000f03f0000000000000000
st_asbinary | \x0101000000000000000000f03f0000000000000000

-Mike


More information about the postgis-users mailing list