Well-Known Text Geometry
geography.format.wktOGC Well-Known Text (WKT) representation of geometry objects. Strings begin with a geometry type keyword, in any letter case (POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, TRIANGLE, POLYHEDRALSURFACE, TIN) optionally followed by Z/M/ZM dimension suffix.
Try a value
Shape
^(?:[Pp][Oo][Ii][Nn][Tt]|[Ll][Ii][Nn][Ee][Ss][Tt][Rr][Ii][Nn][Gg]|[Pp][Oo][Ll][Yy][Gg][Oo][Nn]|[Mm][Uu][Ll][Tt][Ii][Pp][Oo][Ii][Nn][Tt]|[Mm][Uu][Ll][Tt][Ii][Ll][Ii][Nn][Ee][Ss][Tt][Rr][Ii][Nn][Gg]|[Mm][Uu][Ll][Tt][Ii][Pp][Oo][Ll][Yy][Gg][Oo][Nn]|[Gg][Ee][Oo][Mm][Ee][Tt][Rr][Yy][Cc][Oo][Ll][Ll][Ee][Cc][Tt][Ii][Oo][Nn]|[Tt][Rr][Ii][Aa][Nn][Gg][Ll][Ee]|[Pp][Oo][Ll][Yy][Hh][Ee][Dd][Rr][Aa][Ll][Ss][Uu][Rr][Ff][Aa][Cc][Ee]|[Tt][Ii][Nn])\s*(?:[Zz][Mm]|[Zz]|[Mm])?\s*(?:\(|[Ee][Mm][Pp][Tt][Yy])| Value | Length | Shape |
|---|---|---|
| POINT (30 10) | 13 | rejected |
| LINESTRING (30 10, 10 30, 40 40) | 32 | rejected |
| POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10)) | 45 | rejected |
| MULTIPOINT ((10 40), (40 30), (20 20), (30 10)) | 47 | rejected |
| POINT EMPTY | 11 | matches |
| POINT (30 10 | 12 | rejected: 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]
Sources
- [1]Well-known text representation of geometry - Wikipediasecondary source
- [2]OGC Simple Feature Access – Part 1: Common Architecture Standardcatalogue entry
- [3]OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecturestandard
- [4]ST_GeomFromTextdocumentation
- [5]Spatial Functions – DuckDBdocumentation
- [6]Comma Separated Value (.csv) — GDAL documentationdocumentation
- [7]Well-known text representation of coordinate reference systems - Wikipediasecondary source
- [8]Borough Boundariesdataset
Detection notes
OGC Simple Features standard (ISO 19125; OGC 06-103r4, 7.2.1 and 7.2.2): keywords are case-insensitive. DuckDB spatial extension provides ST_GeomFromText for parsing; it reads any letter case, but not TRIANGLE, TIN or POLYHEDRALSURFACE (transform_ext raises an error on those, so they conform to the type but have no geometry value in DuckDB). For discrimination a value counts when a geometry keyword in any letter case is followed by EMPTY or a body holding a coordinate pair, so text such as "Triangle (equilateral)" does not; conforming-only forms are not counted for discrimination.
Use it
$ finetype infer -i "POINT (30 10)" --mode column
→ geography.format.wkt
SELECT ft_infer('POINT (30 10)');
-- → 'geography.format.wkt'CAST({col} AS VARCHAR)Schema
https://meridian.online/schemas/geography.format.wkt · Frictionless type string
finetype taxonomy geography.format.wkt -o json-schema