

Well-known text representation of geometry
source link: https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Well-known text representation of geometry
Jump to navigation Jump to search
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.[1] The current standard definition is in the ISO/IEC 13249-3:2016 standard.[2]
Geometric objects[edit]
WKT can represent the following distinct geometric objects:
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 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.[3]
Type | Examples | |
---|---|---|
Point | POINT (30 10)
| |
LineString | LINESTRING (30 10, 10 30, 40 40)
| |
Polygon | POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))
| |
POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),
|
Type | Examples | |
---|---|---|
MultiPoint | MULTIPOINT ((10 40), (40 30), (20 20), (30 10))
| |
MULTIPOINT (10 40, 40 30, 20 20, 30 10)
| ||
MultiLineString | MULTILINESTRING ((10 10, 20 20, 10 40),
| |
MultiPolygon | MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),
| |
MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),
| ||
GeometryCollection | GEOMETRYCOLLECTION (POINT (40 10),
|
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[edit]
Well-known binary (WKB) representations are typically shown in hexadecimal strings.
The first byte indicates the byte order for the data:
00
: big endian01
: little endian
The next 4 bytes are a 32-bit unsigned integer for the geometry type, as described below:
Type | 2D | Z | M | ZM |
---|---|---|---|---|
Geometry | 0000 |
1000 |
2000 |
3000
|
Point | 0001 |
1001 |
2001 |
3001
|
LineString | 0002 |
1002 |
2002 |
3002
|
Polygon | 0003 |
1003 |
2003 |
3003
|
MultiPoint | 0004 |
1004 |
2004 |
3004
|
MultiLineString | 0005 |
1005 |
2005 |
3005
|
MultiPolygon | 0006 |
1006 |
2006 |
3006
|
GeometryCollection | 0007 |
1007 |
2007 |
3007
|
CircularString | 0008 |
1008 |
2008 |
3008
|
CompoundCurve | 0009 |
1009 |
2009 |
3009
|
CurvePolygon | 0010 |
1010 |
2010 |
3010
|
MultiCurve | 0011 |
1011 |
2011 |
3011
|
MultiSurface | 0012 |
1012 |
2012 |
3012
|
Curve | 0013 |
1013 |
2013 |
3013
|
Surface | 0014 |
1014 |
2014 |
3014
|
PolyhedralSurface | 0015 |
1015 |
2015 |
3015
|
TIN | 0016 |
1016 |
2016 |
3016
|
Triangle | 0017 |
1017 |
2017 |
3017
|
Circle | 0018 |
1018 |
2018 |
3018
|
GeodesicString | 0019 |
1019 |
2019 |
3019
|
EllipticalCurve | 0020 |
1020 |
2020 |
3020
|
NurbsCurve | 0021 |
1021 |
2021 |
3021
|
Clothoid | 0022 |
1022 |
2022 |
3022
|
SpiralCurve | 0023 |
1023 |
2023 |
3023
|
CompoundSurface | 0024 |
1024 |
2024 |
3024
|
BrepSolid | 1025 |
|||
AffinePlacement | 102 |
1102 |
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[edit]
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).[4][5] For example: SRID=4326;POINT(-44.3 60.1)
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.[6]
AGF Text – Autodesk Geometry Format
An extension to OGC's Standard (at the time), to include curved elements; most notably used in MapGuide.[7]
See also[edit]
References[edit]
External links[edit]
Recommend
-
13
A Well-Known URL for Changing Passwords↑ → Abstract This specifica...
-
10
In previous blog posts,we have analyzed different onboarding flows that combine general best practices and tackle indivi...
-
12
Text preprocessing, representation and visualization from zero to hero.Texthero is a python package to work with text data efficiently. It empowers NLP developers with a tool to quickly understand any tex...
-
16
70M stolen AT&T records advertised for sale by well-known hacker
-
9
Well-known SymbolsI was recently asking on public forums if people can name at least three Well-known Symbols in JavaScript without looking up and few could, which gave birth to this post.A well-known symbol is a non-register...
-
11
Bao Fan, a well-known Chinese tech dealmaker, goes missing Bao Fan, a well-known Chinese tech dealmaker, goes missing 19 minutes ago On the evening of February 16th, China Renaissance, a top in...
-
13
Universal Implementation of BFS, DFS, Dijkstra, and A-Star Algorithms ...
-
4
Can’t We Assign a Default Value to the BLOB, TEXT, GEOMETRY, and JSON Data Types?January 12, 2024 Edwin WangOne of our customers wants t...
-
6
Well-known Secrets of AmigaDOS Documented, undocumented, unfinished and useful Early 2024 Table of Contents Got docs?
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK