wiki:HexEncodedWkb

At this point, GEOS has been pretty heavily de-bugged and most of the easy and obvious error cases have been fixed. The errors that remain are usually caused by geometries that are very very similar but not quite. Exporting geometries as human-readable floating-point numbers pushes the ordinates through a binary-to-decimal conversion, which may slightly round and alter them, sometimes making the error case disappear.

In order to export the information with full fidelity, use hex-encoded well-known-binary. Using well-known-binary ensures that the output format is true to the actual binary information, and using hex-encoding allows the information to be pasted into emails or this bug tracker as text strings.

To generate a hex-encoded well-known-binary form of a geometry in PostGIS, use a SQL call like this:

SELECT encode(ST_AsBinary(the_geom),'hex') FROM the_table;
Last modified 7 years ago Last modified on Feb 26, 2010 8:30:00 PM