# Well-Known Text Geometry

Key: `geography.format.wkt`

OGC Well-Known Text (WKT) representation of geometry objects. Strings begin with a geometry type keyword (POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION) optionally followed by Z/M/ZM dimension suffix.

Page: <https://meridian.online/docs/projects/finetype/types/geography/format/wkt>

Samples: `POINT (30 10)`, `LINESTRING (30 10, 10 30, 40 40)`, `POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))`, `MULTIPOINT ((10 40), (40 30), (20 20), (30 10))`, `POINT EMPTY`

## Background

### Origin

Well-known text (WKT) is a text markup language for representing vector geometry objects.[[1]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) The WKT format was originally defined by the Open Geospatial Consortium and described in its Simple Feature Access specification.[[1]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) Part 1 of OGC's Simple Feature Access, the Common Architecture, is also called ISO 19125.[[2]](https://www.ogc.org/standards/sfa/)[[3]](https://docs.ogc.org/is/06-103r4/06-103r4.pdf) Version 1.2.1 of the Common Architecture, OGC document 06-103r4, is dated 2011-05-28.[[3]](https://docs.ogc.org/is/06-103r4/06-103r4.pdf) The OGC 06-103r4 document names John R. Herring as its editor.[[3]](https://docs.ogc.org/is/06-103r4/06-103r4.pdf)

Clause 7 of the OGC standard says each geometry type's Well-known Text Representation can be used both to construct new instances of the type and to convert existing instances to textual form for alphanumeric display.[[3]](https://docs.ogc.org/is/06-103r4/06-103r4.pdf) The OGC standard defines the Well-known Text Representation of Geometry using BNF.[[3]](https://docs.ogc.org/is/06-103r4/06-103r4.pdf) Wikipedia's article on WKT gives the current standard definition as ISO/IEC 13249-3:2016.[[1]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry)

### Use

The OGC standard notes that its examples show integer coordinates but that in general they may be any double precision value.[[3]](https://docs.ogc.org/is/06-103r4/06-103r4.pdf) The OGC standard definition requires a polygon to be topologically closed.[[1]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry)

PostGIS's ST\_GeomFromText constructs a geometry object from the OGC Well-Known text representation.[[4]](https://postgis.net/docs/ST_GeomFromText.html) When ST\_GeomFromText is called without an SRID, PostGIS returns a geometry with no defined spatial reference system (SRID=0).[[4]](https://postgis.net/docs/ST_GeomFromText.html) PostGIS also has its own extended form, EWKT, which includes the spatial reference system identifier, as in SRID=4326;POINT(-44.3 60.1).[[1]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) DuckDB's spatial extension documents ST\_GeomFromText as deserialising a GEOMETRY from a WKT encoded string.[[5]](https://duckdb.org/docs/current/core_extensions/spatial/functions.html) DuckDB's ST\_AsText returns a geometry as a WKT string.[[5]](https://duckdb.org/docs/current/core_extensions/spatial/functions.html)

GDAL's CSV driver assumes that a field named WKT contains WKT geometry.[[6]](https://gdal.org/en/stable/drivers/vector/csv.html) By default, GDAL's CSV driver discards a feature's geometry when writing a .csv file.[[6]](https://gdal.org/en/stable/drivers/vector/csv.html)

Well-known binary (WKB) is the binary equivalent of WKT.[[1]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) WKB values are typically shown as hexadecimal strings.[[1]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) A separate text format, well-known text for coordinate reference systems, has its current definition in ISO 19162:2019.[[7]](https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems) Look for the coordinate reference system in the dataset's documentation or a companion column before you plot, measure or join a plain WKT column. (Meridian's view)

### Where you'll meet it

NYC Open Data's Borough Boundaries CSV stores each borough's outline as a WKT MULTIPOLYGON in a column named the\_geom.[[8]](https://data.cityofnewyork.us/api/views/gthc-hcne/rows.csv?accessType=DOWNLOAD) The Borough Boundaries CSV writes the first vertex of Staten Island's outline as -74.05050806403247 40.566422034161.[[8]](https://data.cityofnewyork.us/api/views/gthc-hcne/rows.csv?accessType=DOWNLOAD)

## Sources

1. [Well-known text representation of geometry - Wikipedia](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) — secondary source
2. [OGC Simple Feature Access – Part 1: Common Architecture Standard](https://www.ogc.org/standards/sfa/) — catalogue entry
3. [OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture](https://docs.ogc.org/is/06-103r4/06-103r4.pdf) — standard
4. [ST\_GeomFromText](https://postgis.net/docs/ST_GeomFromText.html) — documentation
5. [Spatial Functions – DuckDB](https://duckdb.org/docs/current/core_extensions/spatial/functions.html) — documentation
6. [Comma Separated Value (.csv) — GDAL documentation](https://gdal.org/en/stable/drivers/vector/csv.html) — documentation
7. [Well-known text representation of coordinate reference systems - Wikipedia](https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems) — secondary source
8. [Borough Boundaries](https://data.cityofnewyork.us/api/views/gthc-hcne/rows.csv?accessType=DOWNLOAD) — dataset
