MeridianMERIDIAN

Well-Known Text Geometry

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.

Casts to
VARCHAR

Shape

Pattern
^(POINT|LINESTRING|POLYGON|MULTI(POINT|LINESTRING|POLYGON)|GEOMETRYCOLLECTION)\s*(Z|M|ZM)?\s*(\(|EMPTY)
ValueLengthShape
POINT (30 10)13rejected
LINESTRING (30 10, 10 30, 40 40)32rejected
POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))45rejected
MULTIPOINT ((10 40), (40 30), (20 20), (30 10))47rejected
POINT EMPTY11matches
POINT (30 1012rejected: one character short

Background

Origin

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

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] The OGC standard defines the Well-known Text Representation of Geometry using BNF.[3] Wikipedia's article on WKT gives the current standard definition as ISO/IEC 13249-3:2016.[1]

Use

The OGC standard notes that its examples show integer coordinates but that in general they may be any double precision value.[3] The OGC standard definition requires a polygon to be topologically closed.[1]

PostGIS's ST_GeomFromText constructs a geometry object from the OGC Well-Known text representation.[4] When ST_GeomFromText is called without an SRID, PostGIS returns a geometry with no defined spatial reference system (SRID=0).[4] 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] DuckDB's spatial extension documents ST_GeomFromText as deserialising a GEOMETRY from a WKT encoded string.[5] DuckDB's ST_AsText returns a geometry as a WKT string.[5]

GDAL's CSV driver assumes that a field named WKT contains WKT geometry.[6] By default, GDAL's CSV driver discards a feature's geometry when writing a .csv file.[6]

Well-known binary (WKB) is the binary equivalent of WKT.[1] WKB values are typically shown as hexadecimal strings.[1] A separate text format, well-known text for coordinate reference systems, has its current definition in ISO 19162:2019.[7] 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] The Borough Boundaries CSV writes the first vertex of Staten Island's outline as -74.05050806403247 40.566422034161.[8]

Detection notes

OGC Simple Features standard (ISO 19125). DuckDB spatial extension provides ST_GeomFromText for parsing.

Use it

CLI · DuckDB
$ finetype infer -i "POINT (30 10)" --mode column
→ geography.format.wkt

SELECT ft_infer('POINT (30 10)');
-- → 'geography.format.wkt'
Cast expression
CAST({col} AS VARCHAR)

Schema

https://meridian.online/schemas/geography.format.wkt · Frictionless type string

finetype taxonomy geography.format.wkt -o json-schema

Aliases

well_known_text

Type Registry