Well Known Text

On this page Carat arrow pointing down
Warning:
CockroachDB v20.2 is no longer supported as of May 10, 2022. For more details, refer to the Release Support Policy.

The Well Known Text format (hereafter WKT) provides a text representation of a geometric shape. It can be used to:

  • Build instances of various shapes (e.g., using ST_MakePolygon on a Linestring).
  • Convert existing shapes to a text representation for ease of reading.

Each shape in WKT has a tag which says what it is, usually followed by a list of coordinates. For example, here are some common tags:

  • POINT(...)
  • LINESTRING(...)
  • POLYGON((...))

WKT is technically case insensitive, but is sometimes displayed using "CamelCase" for easier reading. For example, one can represent a MultiPolygon as either of:

  • MULTIPOLYGON(...)
  • MultiPolygon(...)

When a shape is made up of homogeneous subcomponents, such as a polygon made up of various points, the subcomponents do not need to have their own tags. For example:

LINESTRING(-88.243385 40.116421, -87.906471 43.038902, -95.992775 36.153980)

Shapes expressed in WKT can have an SRID prepended to the shape and followed by a semicolon, in the form SRID=123;TAG(...). The format is known as Extended Well Known Text (EWKT); it is the same as WKT, with an SRID representation prepended to the data structure.

For example, below is a polygon representing a geometry that uses SRID 4326, which is used to represent latitude and longitude coordinates on the Earth as defined in the WGS84 standard:

SRID=4326;POLYGON((-87.906471 43.038902, -95.992775 36.153980, -75.704722 36.076944, -87.906471 43.038902))

Note:

For more detailed information about the Well Known Text format, see the OGC specification for WKT.

Note:

CockroachDB only supports 2-dimensional geometries.

See also


Yes No
On this page

Yes No