loaders.gl support
| Type | API |
|---|---|
| Loader | TWKBLoader |
| Writer | TWKBWriter |
The TWKB record path
Store the first position. Make nearby points inexpensive.
TWKB is useful when geometry is spatially local and transport size matters. The decoder reconstructs the coordinate sequence from compact integer deltas before exposing the common geometry result.
Coordinate model
Quantized integer coordinates and deltas
Encoding
Variable-length integers with zigzag values
Typical use
Compact vector geometry over APIs or mobile links
Related formats
WKB for general binary geometry; WKT for readable text
Detailed guide
TWKB layout and support details
The reference below covers the compact encoding model, ecosystem support, and the loaders.gl APIs for reading and writing TWKB geometry.
TWKB is a format for serializing vector geometry data into a binary byte buffer, similar to WKB but with an emphasis on minimizing size of the buffer.
Memory Layout
WKB uses IEEE doubles as the coordinate storage format, so for data with lots of spatially adjacent coordinates (typical for GIS data) it wastes precision, i.e. space on redundant coordinate information:
- TWKB only stores the absolute position once, and stores all other positions as delta values relative to the preceding position.
- TWKB Only use as much address space as is necessary for any given value. Practically this means that "variable length integers" or "varints" are used throughout the specification for storing values in any situation where numbers greater than 128 might be encountered.
Ecosystem Support
- PostGIS offers a function to return geometries in TWKB format: ST_AsTWKB.
Versions / History
Unknown.