I have a dump from a version of PostGIS that is no longer supported. It dumps the value of a (lat, long) as 01010000003D2CD49AE6A549409AB1683A3B19F1BF

How can I decode that number (without using PostGIS) to determine the original lat long?

  • How did you create the dump from the old version of PostGIS? That could be EWKB or just plain WKB, but knowing the output format would help. – Evil Genius Apr 25 '16 at 11:52
  • If it was a Geometry type, it's a lon/lat, with a value of {51.296100,-1.068660}. The format appears to be hexadecimal ASCII of WKB (Well-Known Binary). – Vince Apr 25 '16 at 13:33
  • You can get technical details of the WKB format at portal.opengeospatial.org/files/?artifact_id=829. Alternatively, you could use something like JTS. You have said you can not use Postgis, but not if you can use something else. – John Powell Apr 25 '16 at 13:42
  • Converter here rodic.fr/blog/online-conversion-between-geometric-formats returns POINT(51.2961 -1.06866) – Mapperz Apr 26 '16 at 21:31

That output is hex-encoded EWKB, or extended Well-known binary, with a specification provided here.

This example is identical to ISO WKB, since it does not have an SRID or use dimensions beyond 2D (such as Z, M, or ZM). The formats are different otherwise.

You can decode geometry data (i.e. longitude and latitude) from WKB using a wide range of tools available in Python, PHP, R, Perl, etc., or any custom implementation that is capable of implementing the specification.

Also note that you might be able to use the PostGIS dump file with newer versions of PostGIS; see the hard upgrade procedure, which uses utils/postgis_restore.pl to read older formats.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.