Well-known text representation of geometry


Well-known text is a text markup language for representing vector geometry objects. A binary equivalent, known as well-known binary, is used to transfer and store the same information in a more compact form convenient for computer processing but that is not human-readable. The formats were originally defined by the Open Geospatial Consortium and described in their Simple Feature Access. The current standard definition is in the ISO/IEC 13249-3:2016 standard.

Geometric objects

WKT can represent the following distinct geometric objects:
Coordinates for geometries may be 2D, 3D, 4D with an m value that is part of a linear referencing system or 2D with an m value. Three-dimensional geometries are designated by a "Z" after the geometry type and geometries with a linear referencing system have an "M" after the geometry type. Empty geometries that contain no coordinates can be specified by using the symbol EMPTY after the type name.
WKT geometries are used throughout OGC specifications and are present in applications that implement these specifications. For example, PostGIS contains functions that can convert geometries to and from a WKT representation, making them human readable.
The OGC standard definition requires a polygon to be topologically closed. It also states that if the exterior linear ring of a polygon is defined in a counterclockwise direction it will be seen from the "top". Any interior linear rings should be defined in opposite fashion compared to the exterior ring, in this case, clockwise.
The following are some other examples of geometric WKT strings:

GEOMETRYCOLLECTION,LINESTRING)
POINT ZM
POINT M
POINT EMPTY
MULTIPOLYGON EMPTY
TRIANGLE)
TIN ), ))
POLYHEDRALSURFACE Z ),
),
),
),
),
)
)

Well-known binary

Well-known binary representations are typically shown in hexadecimal strings.
The first byte indicates the byte order for the data:
The next 4 bytes are a 32-bit unsigned integer for the geometry type, as described below:
Type2DZMZM
Geometry0000100020003000
Point0001100120013001
LineString0002100220023002
Polygon0003100320033003
MultiPoint0004100420043004
MultiLineString0005100520053005
MultiPolygon0006100620063006
GeometryCollection0007100720073007
CircularString0008100820083008
CompoundCurve0009100920093009
CurvePolygon0010101020103010
MultiCurve0011101120113011
MultiSurface0012101220123012
Curve0013101320133013
Surface0014101420143014
PolyhedralSurface0015101520153015
TIN0016101620163016
Triangle0017101720173017
Circle0018101820183018
GeodesicString0019101920193019
EllipticalCurve0020102020203020
NurbsCurve0021102120213021
Clothoid0022102220223022
SpiralCurve0023102320233023
CompoundSurface0024102420243024
BrepSolid1025
AffinePlacement1021102

Each data type has a unique data structure, such as the number of points or linear rings, followed by coordinates in 64-bit double numbers.
For example, the geometry POINT is represented as: 000000000140000000000000004010000000000000, where:
; EWKT and EWKBExtended Well-Known Text/Binary : A PostGIS-specific format that includes the spatial reference system identifier and up to 4 ordinate values. For example: SRID=4326;POINT to locate a longitude/latitude coordinate using the WGS 84 reference coordinate system.
; AGF TextAutodesk Geometry Format : An extension to OGC's Standard, to include curved elements; most notably used in MapGuide.

Software support

Database engines

*