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
TWKBWKB 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
Geometry0000100020003000
Point0001100120013001
LineString0002100220023002
Polygon0003100320033003
MultiPoint0004100420043004
MultiLineString0005100520053005
MultiPolygon0006100620063006
GeometryCollection✅ *0007100720073007
CircularString0008100820083008
CompoundCurve0009100920093009
CurvePolygon0010101020103010
MultiCurve0011101120113011
MultiSurface0012101220123012
Curve0013101320133013
Surface0014101420143014
PolyhedralSurface0015101520153015
TIN0016101620163016
Triangle0017101720173017
Circle0018101820183018
GeodesicString0019101920193019
EllipticalCurve0020102020203020
NurbsCurve0021102120213021
Clothoid0022102220223022
SpiralCurve0023102320233023
CompoundSurface0024102420243024
BrepSolid1025
AffinePlacement1021102

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.