PostGIS – Format of Raw Geometry Column in PostgreSQL

geometrypostgispostgresql

It doesn't seem to be a WKB, since it's basically a string, so what is it?

enter image description here

Best Answer

It is the hexadecimal rendition (two characters per byte) of the EWKB format.

Per the documentation:

The "canonical forms" of a PostgreSQL type are the representations you get with a simple query (without any function call) and the one which is guaranteed to be accepted with a simple insert, update or copy. For the PostGIS 'geometry' type these are:

- Output
  - binary: EWKB
        ascii: HEXEWKB (EWKB in hex form)
- Input
  - binary: EWKB
        ascii: HEXEWKB|EWKT 

For example this statement reads EWKT and returns HEXEWKB in the process of canonical ascii input/output:

=# SELECT 'SRID=4;POINT(0 0)'::geometry;

geometry
----------------------------------------------------
01010000200400000000000000000000000000000000000000
(1 row)