Skip to main content

WKB - Well-Known Binary

ogc-logo

Well-Known Binary (WKB) is a binary version of Well-known Text

Overview​

Well-known binary (WKB) representations are typically shown in hexadecimal strings.

Variations​

  • EKWB - Adds spatial reference systems
  • TWKB

Alternatives​

  • WKT
  • GeoJSON Geometry
  • GML Geometry
FormatSupportDescription
WKB❌
TWKB❌WKB variant reduces binary size ~2x.

TWKB uses varints, precision truncation and zigzag point encoding to reduce binary size ~2x (however compressed size reduction is less)

Version History​

TBA.

Ecosystem Support​

  • PostGIS offers a function to return geometries in TWKB format: ST_AsTWKB.

Format Details​

The first byte indicates the byte order for the data:

  • 00 : big endian
  • 01 : little endian

The next 4 bytes are a 32-bit unsigned integer for the geometry type, as described below:

TypeSupported2DZMZM
Geometry✅0000100020003000
Point✅0001100120013001
LineString✅0002100220023002
Polygon✅0003100320033003
MultiPoint✅0004100420043004
MultiLineString✅0005100520053005
MultiPolygon✅0006100620063006
GeometryCollection✅ *0007100720073007
CircularString❌0008100820083008
CompoundCurve❌0009100920093009
CurvePolygon❌0010101020103010
MultiCurve❌0011101120113011
MultiSurface❌0012101220123012
Curve❌0013101320133013
Surface❌0014101420143014
PolyhedralSurface❌0015101520153015
TIN❌0016101620163016
Triangle❌0017101720173017
Circle❌0018101820183018
GeodesicString❌0019101920193019
EllipticalCurve❌0020102020203020
NurbsCurve❌0021102120213021
Clothoid❌0022102220223022
SpiralCurve❌0023102320233023
CompoundSurface❌0024102420243024
BrepSolid❌1025
AffinePlacement❌1021102

Remarks:

  • Many implementations, including loaders.gl, only handle the core GeoJSON geometry equivalents (points, line strings, polygons and to a varying degrees geometry collections of the same).
  • GeometryCollection can be difficult for some clients to handle.