[gdal-dev] PostGIS does not close a ring created by ogr2ogr

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Mon Sep 8 05:24:02 PDT 2014


Hi,

Anybody interested in biting some bytes of WKB? Thorough description of the
trouble is in Stackexchange
http://gis.stackexchange.com/questions/113029/polygon-from-line-creation-problem

Summary:
User has converted a linestring from dxf format into PostGIS with ogr2ogr.
By staring at the WKB the linestring seems to make a closing ring with first
and last vertex having exactly same coordinates which are in binary:
D89E591A2DD4284123D92354DF65F440
However, PostGIS claims that the ring is not closed and it can't make a
polygon with ST_MakePolygon. ST_MakePolygon is successful if WKB is first
converted into WKT and then back to WKB with PostGIS. There are some
differences in the beginning of WKB created by ogr2ogr and PostGIS. GDAL
writes this before the coordinates begin (separates with dashes from where I
believe to be logical breaks) 
01-02000020-B46B0000-7D000000

PostGIS version writes different geometry type and WKB is a few bytes shorter:
01-02000000-7D000000

So GDAL writes "02000020" instead of "02000000" but it also writes bytes
"B46B0000" which do not have any equivalent it the PostGIS WKB. After these
bytes WKB seems to be identical.

I am curious to get an explanation for what happens.

-Jukka Rahkonen- 








More information about the gdal-dev mailing list