| 2 | |
| 3 | Frequently Asked Questions about PostGIS extension. |
| 4 | |
| 5 | == How to create geometry from hex-encoded WKB using SQL? == |
| 6 | |
| 7 | This is two-steps operation which can be executed in single SQL statement. The steps include: |
| 8 | 1. Convert WKB data in hexadecimal form to raw binary using PostgreSQL function [http://www.postgresql.org/docs/8.3/static/functions-binarystring.html decode]. |
| 9 | 2. Construct geometry object from WKB in raw binary form. |
| 10 | |
| 11 | Example: |
| 12 | |
| 13 | {{{ |
| 14 | !sql |
| 15 | =# SELECT ST_AsText(ST_GeomFromWKB(decode('0101000000e5d022dbf93e2e40dbf97e6abc743540', 'hex'), 4326)); |
| 16 | st_astext |
| 17 | ---------------------- |
| 18 | POINT(15.123 21.456) |
| 19 | }}} |