[geos-devel] WKB representation is EWKB, not OGC

Mike Toews mwtoews at gmail.com
Thu Dec 5 01:40:04 PST 2013

Ok, the WKB Reader/Writer APIs make sense from the perspective of a
2D-only OGC spec, which is when they were written. I think the GEOS
documentation just needs to be a bit more clear

Yeah, it would be wise if WKBReader could parse the OGC WKB too (sort
of http://trac.osgeo.org/geos/ticket/466), as PostGIS does via
ST_AsBinary or even ST_AsEWKT with a warning. The WKBWriter could also
add an option to emit OGC-spec outputs, but that's just getting fancy.
I'm not aware of anyone actually reading/writing non-2D WKB with GEOS
that would benefit from this, but you never know.

GEOS correctly parses EWKB 3D-M and 4D-ZM geometries, but completely
ignores the M value (http://trac.osgeo.org/geos/ticket/460). Note that
the WKT reader also reads 3D-M geometries, but misinterprets M as Z,
which is different than the behaviour with WKB, which just makes a 2D
geometry http://trac.osgeo.org/geos/ticket/676

Great backgrounder from 9 years ago here:


On 5 December 2013 18:38, Paul Ramsey <pramsey at cleverelephant.ca> wrote:
> Right, at the time JTS/GEOS came into being, the only standard WKB was
> 2D WKB, so from an interop point of view, it was golden.
> It might be time to update the reader to ingest more variants, and the
> writer to emit ISO standard 3D/4D variants. That would imply also
> updating the WKT writer and reader, etc, etc. And how about an M
> coordinate? :)
> P.
> On Wed, Dec 4, 2013 at 8:51 PM, Martin Davis <mtnclimb at telus.net> wrote:
>> The JTS doc for the WKBReader says:
>> "It also partially handles the Extended WKB format used by PostGIS".
>> My recollection is that at the time JTS was original developed, the OGC SFS
>> spec was at version 1.1 (99-049), and did not specify 3D support for WKB.
>> PostGIS extended the spec to allow this - but when the OGC got around to
>> specifying it, it did so in a different way. Hence the discrepancy.

More information about the geos-devel mailing list