Well-known text (WKT) is a text
markup language for representing
vector
Vector most often refers to:
*Euclidean vector, a quantity with a magnitude and a direction
*Vector (epidemiology), an agent that carries and transmits an infectious pathogen into another living organism
Vector may also refer to:
Mathematic ...
geometry
Geometry (; ) is, with arithmetic, one of the oldest branches of mathematics. It is concerned with properties of space such as the distance, shape, size, and relative position of figures. A mathematician who works in the field of geometry is ...
objects. A
binary
Binary may refer to:
Science and technology Mathematics
* Binary number, a representation of numbers using only two digits (0 and 1)
* Binary function, a function that takes two arguments
* Binary operation, a mathematical operation that ta ...
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
The Open Geospatial Consortium (OGC), an international voluntary consensus standards organization for geospatial content and location-based services, sensor web and Internet of Things, GIS data processing and data sharing. It originated in 199 ...
(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
Point or points may refer to:
Places
* Point, Lewis, a peninsula in the Outer Hebrides, Scotland
* Point, Texas, a city in Rains County, Texas, United States
* Point, the NE tip and a ferry terminal of Lismore, Inner Hebrides, Scotland
* Point ...
, MultiPoint
*
LineString, MultiLineString
*
Polygon
In geometry, a polygon () is a plane figure that is described by a finite number of straight line segments connected to form a closed ''polygonal chain'' (or ''polygonal circuit''). The bounded plane region, the bounding circuit, or the two to ...
, MultiPolygon,
Triangle
A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry. A triangle with vertices ''A'', ''B'', and ''C'' is denoted \triangle ABC.
In Euclidean geometry, any three points, when non- colline ...
*
PolyhedralSurface
*TIN (
Triangulated irregular network
In computer graphics, a triangulated irregular network (TIN) is a representation of a continuous surface consisting entirely of triangular facets (a triangle mesh), used mainly as Discrete Global Grid in primary elevation modeling.
The vertic ...
)
*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
EMPTY
after the type name.
WKT geometries are used throughout OGC specifications and are present in applications that implement these specifications. For example,
PostGIS
PostGIS ( ) is an open source software program that adds support for geographic objects to the PostgreSQL object-relational database. PostGIS follows the Simple Features for SQL specification from the Open Geospatial Consortium (OGC).
Technica ...
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.)
GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))
POINT ZM (1 1 5 60)
POINT M (1 1 80)
POINT EMPTY
MULTIPOLYGON EMPTY
TRIANGLE((0 0 0,0 1 0,1 1 0,0 0 0))
TIN (((0 0 0, 0 0 1, 0 1 0, 0 0 0)), ((0 0 0, 0 1 0, 1 1 0, 0 0 0)))
POLYHEDRALSURFACE Z ( PATCHES
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),
((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)),
((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
((1 1 1, 1 0 1, 0 0 1, 0 1 1, 1 1 1)),
((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)),
((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1))
)
Well-known binary
Well-known binary (WKB) representations are typically shown in
hexadecimal strings.
The first
byte
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable uni ...
indicates the
byte order
In computing, endianness, also known as byte sex, is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most sig ...
for the data:
*
00
: big endian
*
01
: 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
POINT(2.0 4.0)
is represented as:
000000000140000000000000004010000000000000
, where:
* 1-byte integer
00
or 0: big endian
* 4-byte integer
00000001
or 1: POINT (2D)
* 8-byte float
4000000000000000
or 2.0: ''x''-coordinate
* 8-byte float
4010000000000000
or 4.0: ''y''-coordinate
Format variations
; ''EWKT'' and ''EWKB'' – ''Extended Well-Known Text/Binary'' : A
PostGIS
PostGIS ( ) is an open source software program that adds support for geographic objects to the PostgreSQL object-relational database. PostGIS follows the Simple Features for SQL specification from the Open Geospatial Consortium (OGC).
Technica ...
-specific format that includes the
spatial reference system identifier
A spatial reference system (SRS) or coordinate reference system (CRS) is a framework used to precisely measure locations on the surface of the Earth as coordinates. It is thus the application of the abstract mathematics of coordinate systems and ...
(SRID) and up to 4 ordinate values (XYZM). For example:
SRID=4326;POINT(-44.3 60.1)
to locate a longitude/latitude coordinate using the
WGS 84
The World Geodetic System (WGS) is a standard used in cartography, geodesy, and satellite navigation including GPS. The current version, WGS 84, defines an Earth-centered, Earth-fixed coordinate system and a geodetic datum, and also descri ...
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
Autodesk, Inc. is an American multinational software corporation that makes software products and services for the architecture, engineering, construction, manufacturing, media, education, and entertainment industries. Autodesk is headquartere ...
Geometry Format : An extension to
OGC's Standard (at the time), to include curved elements; most notably used in
MapGuide.
See also
*
Simple Features
Simple Features (officially Simple Feature Access) is a set of standards that specify a common storage and access model of geographic feature made of mostly two-dimensional geometries (point, line, polygon, multi-point, multi-line, etc.) used by g ...
*
Geography Markup Language
The Geography Markup Language (GML) is the XML grammar defined by the Open Geospatial Consortium (OGC) to express geographical features. GML serves as a modeling language for geographic systems as well as an open interchange format for geographi ...
*
Well-known text representation of coordinate reference systems
Well-known text representation of coordinate reference systems (WKT or WKT-CRS) is a text markup language for representing spatial reference systems and transformations between spatial reference systems. The formats were originally defined by the ...
References
External links
Simple Feature AccessSpecification
BNF Notation of WKT{{Webarchive, url=https://web.archive.org/web/20131029211531/http://svn.osgeo.org/postgis/trunk/doc/bnf-wkt.txt , date=2013-10-29
EBNF Notation of WKTOnline conversion between geometry objects representations
GIS file formats
Markup languages
de:Well Known Text