Spatial Data Representations in Spatialite

03 Jan 2013

To get things straight, there are basically two spatial data binary (BLOB) representations supported by Spatialite: WKB and internal. And in the meantime, there are several spatial data text representations also supported, including WKT, GML, KML and GeoJSON and so on.

WKB (Well-Known Binary) and WKT (Well-Known Text) (see footnote 3) are OGC standards designed to be exchangeable across different platforms. The internal representation of any geometry within Spatialite is specific to Spatialite, therefore it is not intended to support data exchange between different platforms but for efficiency and robustness (See footnote 1).

Whatever the representations they are, they are all representing geometries (see footnote 2) in space, which are detailed here:

The OpenGIS geometry model

One thing worth noticing in the model is Polygon is simply a set of __LineString__s, and one of the __LineString__s is the exterior ring (one and only!).

To know more concrete implementation details of the representations for WKT, WKB and Spatialite internal blob, see these links:

Another confusion when using Spatialite for me was seeing some coordinate encodings like this: XY, XYM, XYZ and XYZM. This is some standard defined by OGC and they are actually dimensional models:

M is a relative measure that defines the scale of the geometry (like the scales in a map).

Other References

Wikipeida Well Known Text


1 Blob is good for saving space for storage, and faster to process by predefined specific operations on bytes

2 Points, Lines and Polygons

3 WKT is in ASCII texts