Well-known text representation of geometry

Well-known text (WKT) is a text markup language for representing vector geometry objects. A binary equivalent, known as well-known binary (WKB), 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 (OGC) 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:
 * Point, MultiPoint
 * LineString, MultiLineString
 * Polygon, MultiPolygon, Triangle
 * PolyhedralSurface
 * TIN (Triangulated irregular network)
 * GeometryCollection

Coordinates for geometries may be 2D (x, y), 3D (x, y, z), 4D (x, y, z, m) with an m value that is part of a linear referencing system or 2D with an m value (x, y, m). 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  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, then 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: (Note: Each item below is an individual geometry.)

Well-known binary
Well-known binary (WKB) representations are typically shown in hexadecimal strings.

The first byte indicates the byte order for the data:
 * : big endian
 * : little endian

The next 4 bytes are a 32-bit unsigned integer for the geometry type, as described below:

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  is represented as: , where:
 * 1-byte integer  or 0: big endian
 * 4-byte integer  or 1: POINT (2D)
 * 8-byte float  or 2.0: x-coordinate
 * 8-byte float  or 4.0: y-coordinate

Format variations

 * EWKT and EWKB – Extended Well-Known Text/Binary : A PostGIS-specific format that includes the spatial reference system identifier (SRID) and up to 4 ordinate values (XYZM). For example:   to locate a longitude/latitude coordinate using the WGS 84 reference coordinate system. It also supports circular curves, following elements named (but not fully defined) within the original WKT: CircularString, CompoundCurve, CurvePolygon and CompoundSurface.
 * AGF Text – Autodesk Geometry Format : An extension to OGC's Standard (at the time), to include curved elements; most notably used in MapGuide.