I'm looking for some low level information or reading or reference material which explains how most GIS databases store the geometry data type in binary form, because - I never really investigated it at such a low level database storage mechanism level (ie: It's for my curiosity really). It's like long division - I kinda missed it in school somewhere along the way.

So I understand what binary is, but am looking to understand this in the context of a storage mechanism of geometry.

For example, the postGIS documentation mentions:

The following SQL query shows an example of WKB representation (the call to encode() is required to convert the binary output into an ASCII form for printing):

SELECT encode( ST_AsBinary(ST_GeometryFromText('LINESTRING(0 0,1 0)')), 'hex'); 01020000000200000000000000000000000000000000000000000000000000f03f0000000000000000

In the above instance, the line is at coords 0,0 and 1,0 (of some random arbitrary coordinate system.) and then gets converted to binary and then encoded out as hex, for printing. I get that, no dramas.

So does this mean that geometry storage is a simple set of coord values, representative of vertexes, with some geometry type flag, and a coord system reference, simply stored as a binary value?

If there is some reference material or reading available that explains the above in more detail that would be great.

Note - context for this is non-commercial OGC implemented database (so not ESRI File Geodatabases, or Oracle as two examples). Ive used postgres as the example here.

  • 2
    It's a mistake to assume that all GIS databases store data the same way (Oracle, SQL Server, PostgeSQL and DB2 all have very different native storage). In fact, most databases don't use WKB. It's simply enough that they all can expose data in WKB. If you want to focus this question on PostgreSQL, then you can Edit it to ask about the open-source binary PG implementation, but it would be better to actually research it first.
    – Vince
    Aug 22, 2021 at 15:39
  • 1
    You can start studying the structure of the original WKB from the standard OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture.
    – user30184
    Aug 22, 2021 at 17:48
  • apologies I did originally have a caveat somewhere that said 'OGC implementations only, not sure where that went..... My question was written in specific context to OGC, not commercial database. ill flag as postGIS for now as thats the examples im using, thanks for picking that up.
    – nr_aus
    Aug 23, 2021 at 3:36

1 Answer 1


WKB presentation is defined in the OGC standards for Simple Feature Access https://www.ogc.org/standards/sfa. The details are in the document https://portal.ogc.org/files/?artifact_id=25355, Chapter 8.2.8 Description of WKBGeometry representations. This image that is taken from the standard shows the structure of the BLOB by using a polygon geometry as an example.

enter image description here

Databases can store geometries as they wish but all OGC compliant databases must return WKB with a standardized function ST_AsBinary.

  • great thanks for that. i have been reading that link you sent, cheers again.
    – nr_aus
    Aug 24, 2021 at 3:11
  • Im just goign to slightly reword the question and then accept the above as the answer, as this is what I was really wanting - that and the other link.
    – nr_aus
    Aug 26, 2021 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.