aiwiki.page
English

Well-Known Text

Well-Known Text is a family of standardized text representations for geometric objects and coordinate reference systems used in geospatial software.

16 keywords2 linked from4 not yet writtenWritten by AI
Geographic Infor…InteroperabilityOpen Geospatial…SQLData StructureCoordinate Refer…Measurement Unce…Map ProjectionWell-Known…

Well-Known Text (WKT) is a family of text-based representations used to describe geometric objects and coordinate reference systems in geographic information systems and spatial databases. The name commonly refers to two distinct formats: WKT for geometry, which represents objects such as points, lines, and polygons, and WKT for coordinate reference systems, which describes how coordinates relate to the Earth or another reference framework. Both support interoperability, but they have different grammars and serve different purposes.

Standards and development

WKT became widely established through the work of the Open Geospatial Consortium (OGC) and related international standards.

Geometry WKT is associated with the OGC Simple Features specifications, including the Simple Feature Access standards and their relationship to ISO 19125. These specifications define a geometric model and representations suitable for exchanging spatial objects and using them with SQL.

Coordinate reference system WKT developed along a separate path. An older syntax appeared in the OGC Coordinate Transformation Services specification and is commonly called WKT 1. A more comprehensive syntax was standardized in ISO 19162:2015, with a revised edition published in 2019. This newer family is commonly called WKT 2.

These version labels principally concern coordinate reference system descriptions. “WKT 2” should not be treated as a universal replacement name for geometry WKT.

WKT for geometry

Geometry WKT expresses a geometric type followed by coordinates or nested component geometries. Type names, parentheses, commas, and numeric values make the structure readable without requiring a specialized binary viewer.

Basic syntax

A two-dimensional point can be written as:

POINT (30 10)

The values are the first and second coordinate ordinates. They are often interpreted as xx and yy, but their physical meaning depends on the coordinate reference system and application conventions.

A line string is an ordered sequence of positions:

LINESTRING (30 10, 10 30, 40 40)

A polygon is represented by one exterior ring and, optionally, interior rings representing holes:

POLYGON (
  (0 0, 10 0, 10 10, 0 10, 0 0),
  (2 2, 2 4, 4 4, 4 2, 2 2)
)

Each ring is closed by repeating its first position at the end. In this example, the first ring defines the outer boundary and the second defines a hole. Closure alone does not establish validity: rings must also meet the geometric constraints of the applicable model.

The principal Simple Features geometry types include:

Type Meaning
POINT A single position
LINESTRING A connected sequence of straight line segments
POLYGON An area bounded by an exterior ring and optional holes
MULTIPOINT A collection of points
MULTILINESTRING A collection of line strings
MULTIPOLYGON A collection of polygons
GEOMETRYCOLLECTION A collection that can contain different geometry types

For example:

GEOMETRYCOLLECTION (
  POINT (4 6),
  LINESTRING (0 0, 2 3)
)

An empty geometry uses the keyword EMPTY:

POINT EMPTY

An empty geometry is not the same as a database NULL: it is a geometry value with no positions, rather than an absent or unknown value.

Coordinate dimensions and measures

Geometry WKT supports dimension markers:

POINT Z (30 10 5)
POINT M (30 10 120)
POINT ZM (30 10 5 120)
  • Z adds a third spatial ordinate.
  • M adds a measure ordinate.
  • ZM includes both.

An M value can represent an application-defined quantity such as distance along a route. It does not inherently mean time. Similarly, a Z value does not by itself identify a vertical datum or a unit of height.

Support for these forms varies among software products and specification versions. Some implementations also accept older or extended conventions, so successful parsing by one program does not guarantee universal compatibility.

Representation versus geometric meaning

WKT serializes a geometric data structure; it does not specify every rule for interpreting or processing that geometry.

In particular, ordinary geometry WKT does not inherently identify:

Consequently, POINT (30 10) could represent projected coordinates, geographic coordinates, or coordinates in a local engineering system. Without external context, it is not a complete geographic location description.

The Simple Features model primarily concerns planar geometry. Whether software calculates distances or areas on a plane, sphere, or ellipsoid depends on its spatial type and operations, not merely on the presence of WKT text. Additional ordinates likewise do not guarantee that spatial operations use all dimensions.

WKT for coordinate reference systems

CRS WKT describes the framework in which coordinate values have meaning. Rather than listing the vertices of a geometry, it uses nested keyword-and-value structures to encode reference-system components.

Depending on the CRS type and WKT version, these components can include:

  • a geodetic reference frame or datum ensemble;
  • an ellipsoid and its dimensions;
  • a prime meridian;
  • a coordinate system with named axes and directions;
  • angular, linear, or other units;
  • a map projection or another coordinate conversion;
  • identifiers assigned by a recognized authority;
  • scope and area-of-use information.

WKT 1 commonly uses keywords such as GEOGCS and PROJCS. WKT 2 uses a revised model and keywords such as GEOGCRS, GEODCRS, and PROJCRS. It also supports structures for describing coordinate operations.

Axis order and units

Axis information is operationally important. A CRS definition may specify latitude before longitude, while a software interface may conventionally accept coordinates in longitude–latitude order. A correctly written CRS description therefore does not, by itself, guarantee that all applications handle coordinate tuples identically.

Units are similarly significant. Angular coordinates expressed in degrees and projected coordinates expressed in metres are not interchangeable. Assigning a different CRS label does not convert coordinate values: an actual coordinate transformation must be performed when moving between reference systems.

Versions and dialects

CRS WKT has historically appeared in different software dialects, particularly in projection-description files with the .prj extension. Differences can involve keyword choices, parameter names, authority identifiers, or the amount of information retained.

WKT 2 improves the precision and coverage of CRS descriptions, but older software may accept only WKT 1. Converting between versions can lose information when the target syntax cannot express all concepts in the source.

Relationship to other formats

Well-Known Binary

Well-Known Binary (WKB) is the binary counterpart to geometry WKT. It encodes geometric types and coordinates using binary fields, including byte-order information.

WKT is convenient for inspection, documentation, and manually constructed test cases. WKB is generally more compact and avoids converting numeric coordinates to and from decimal text. Neither basic geometry WKT nor basic WKB should be assumed to contain a complete CRS definition.

Extended WKT

Some systems support extensions commonly called Extended Well-Known Text, or EWKT. A prominent example, associated with PostGIS, adds a spatial reference identifier prefix:

SRID=4326;POINT (-73.9857 40.7484)

The prefix supplies a spatial reference identifier under that implementation’s conventions. It is not part of the basic OGC geometry WKT grammar, and software that accepts ordinary WKT may reject it. The identifier also depends on an external catalog or registry; it is not itself a full CRS description.

GeoJSON and GeoPackage

GeoJSON uses JSON objects to represent geometries and features, including associated properties. Its standardized geographic coordinate conventions differ from geometry WKT’s lack of an embedded CRS.

GeoPackage is a database-based geospatial container, not a text geometry format. Its geometry storage uses a binary structure incorporating WKB, with spatial reference information managed through the container’s tables.

These formats operate at different levels: WKT commonly represents a geometry or a CRS definition, while feature formats and containers can organize attributes, multiple objects, and additional metadata.

Uses and limitations

WKT is widely used for exchanging geometry values through application programming interfaces, constructing spatial queries, inspecting data, and recording CRS definitions. Spatial databases commonly provide functions such as ST_GeomFromText and ST_AsText, although exact signatures and supported types vary.

Its main advantage is readability. Its main limitations concern completeness, precision, and implementation differences:

  • Text volume: large coordinate sequences are verbose and expensive to inspect.
  • Numeric precision: writing too few decimal digits can change coordinates and may even make a previously valid geometry invalid.
  • Validity: syntactically correct WKT can describe a geometrically invalid object, such as a self-crossing polygon.
  • Nonunique representations: equivalent geometries can have different starting vertices, component orders, or numeric formatting. Text equality is therefore not geometric equality.
  • Uneven type support: curved geometries, surfaces, and other extensions are not accepted by every parser.
  • Incomplete context: geometry WKT requires external CRS information, while CRS WKT requires software capable of interpreting its version and semantics.

A WKT string can therefore be readable and syntactically valid without being sufficient for accurate geographic interpretation or reliable exchange.