#57: WKT Is for Your Eyes. WKB Is for Your CPU

Share

Both formats represent identical geometry. They’re optimized for opposite purposes. Confusing them in production systems costs you precision, bandwidth, and latency.

WKT (Well-Known Text) is a human-readable string: POINT(30.123456789 10.987654321). To parse it, the computer scans characters, finds delimiters, and converts ASCII text into binary numbers. Expensive. The inverse—formatting a binary coordinate as text—truncates precision. 1/3 in IEEE 754 is exact in binary. Printed as text, it becomes 0.333333... (truncated). Round-trip through WKT and coordinates drift.

WKB (Well-Known Binary) is a byte stream encoding geometry directly as IEEE 754 doubles. 01010000... maps directly to memory. No parsing. No conversion. Just memcpy. Coordinates remain bit-for-bit exact. WKB is typically 50% smaller than the equivalent WKT string.

The performance gap is brutal. A client parsing a million WKT geometries burns CPU decoding text. The same client reading WKB copies memory. One operation is 100x slower than the other.

Precision matters. Spatial joins fail on coordinates that have drifted 0.000001 degrees from round-tripping through text. Buffer calculations compound the error. Use WKB to avoid it entirely.

Usage: ST_AsText() when you’re debugging in a SQL console. ST_AsBinary() or raw geometry columns for all production APIs. Let libraries (GEOS, Shapely, PostGIS drivers) handle binary decoding invisibly.

The rule: Text is lossy. Binary is truth. Never serialize to WKT in a production pipeline.

Whenever you’re ready, here are 4 ways I can help you grow in GIS & spatial data:

​Spatial Lab​ – My private community where GIS professionals, data engineers, and analysts connect, swap workflows, and build repeatable systems together.

​Modern GIS Accelerator​ – A guided program to help you break out of legacy GIS habits and learn modern, scalable workflows.

​Career Compass​ – A career-focused program designed to help GIS pros navigate the job market, sharpen their pitch, and find roles beyond traditional GIS paths.

​Sponsorship​: Interested in sponsoring this newsletter (or other content)? ​Learn more here​ and fill out the form to get in touch!

#56: Convenience in SQL Often Means Congestion in the Network

Prev
Comments
Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Get every update, in your inbox.
Get every update, in your inbox.
Get every update, in your inbox.
One tip, every day
Get every update, in your inbox.
Subscribe below and join 11,000+ others learning modern GIS.