[postgis-users] from EWKB to WKB

Denis Rouzaud denis.rouzaud at gmail.com
Thu Apr 25 05:40:41 PDT 2013


Hi

Thank you all for your answers.

I haven't been clear enough.

I am writing a QGIS plugin to use the Postgres 91 plus trigger [0] to do 
rollbacks.

I want to retrieve the geometry and I have access to the it as a EWKB 
string. As I am in QGIS (python API), I don't have direct access to 
Postgis functions.

What I need is to cast the string from EWKB to WKB to reconstruct a QGIS 
geometry [1]

Is this possible?

Thanks again,

Denis

[0 ] http://wiki.postgresql.org/wiki/Audit_trigger_91plus
[1] 
http://qgis.org/api/classQgsGeometry.html#a8723d0f5006afb6ea43c1fa1029879d8





On 04/25/2013 02:32 PM, Mike Toews wrote:
> 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
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130425/27b092fd/attachment.html>


More information about the postgis-users mailing list