Well-known text
Well-known text (WKT) is a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects and transformations between spatial reference systems. A binary equivalent, known as well-known binary (WKB) is used to transfer and store the same information on databases, such as PostGIS and DB2. The formats were originally defined by the Open Geospatial Consortium (OGC) and described in their Simple Feature Access and Coordinate Transformation Service specifications. The current standard definition is in the ISO/IEC 13249-3:2011 standard, "Information technology -- Database languages -- SQL multimedia and application packages -- Part 3: Spatial".
Contents |
[edit] Geometric objects
Geometric objects that can be represented with WKT are: points, lines, polygons, TINs and polyhedrons. Multi geometries are available to represent more than one geometry of the same dimension in a single object, and geometries of different dimensions can be stored in a geometry collection.
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 which 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.
| Type | Examples | |
|---|---|---|
| Point | POINT (30 10) |
|
| LineString | LINESTRING (30 10, 10 30, 40 40) |
|
| Polygon | POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10)) |
|
POLYGON ((35 10, 10 20, 15 40, 45 45, 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, 10 40, 45 40, 30 20)), |
|
MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), |
||
The following are some other examples of geometric WKT strings:
GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10)) POINT ZM (1 1 5 60) POINT M (1 1 80) POINT EMPTY MULTIPOLYGON EMPTY
| 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 |
| Triangle | 0017 |
1017 |
2017 |
3017 |
| 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 |
[edit] Transformations
A WKT format is defined to describe the transformation methods and parameters used to convert coordinates between two different spatial reference systems.
Below are two examples of WKT transformation descriptions.
PARAM_MT["Mercator_2SP", PARAMETER["semi_major",6370997.0], PARAMETER["semi_minor",6370997.0], PARAMETER["central_meridian",180.0], PARAMETER["false_easting",-500000.0], PARAMETER["false_northing",-1000000.0], PARAMETER["standard parallel 1",60.0]] PARAM_MT["Affine", PARAMETER["num_row",3], PARAMETER["num_col",3], PARAMETER["elt_0_1",1], PARAMETER["elt_0_2",2], PARAMETER["elt 1 2",3]]
[edit] RDBMS Engines that provide support
- Postgresql with PostGIS Module 1.3
- Oracle Spatial 9i, 10g, 11g
- MySQL since 4.1[1]
- IBM DB2 LUW 9, 10 with Spatial Extender
- IBM DB2 for z/OS 9, 10 with Spatial Support
- IBM Netezza with Netezza Spatial
- IBM Informix 9,10,11 with Spatial datablade module
- Microsoft SQL Server 2008 R2
- SpatiaLite
- Teradata 6.1, 6.2, 12, 13 (native in 13 through add-in in previous versions)
- Ingres GeoSpatial
- altibase 5.x
[edit] APIs that provide support
- JTS Topology Suite (Java)
- OpenLayers (JavaScript)
- OpenScales (ActionScript)
- GDAL (C/C++ with bindings to Java, Python, and others)
- Shapely (Python): See Shapely Documentation and Shapely in PyPI
[edit] Variations
- EWKT and EWKB – Extended Well-Known Text/Binary – A PostGIS-specific format that includes the spatial reference system identifier (SRID).[2] For example:
SRID=4326;POINT(-44.3 60.1)to locate a longitude/latitude coordinate using the WGS 84 reference coordinate system. - AGF Text – Autodesk Geometry Format – An extension to OGC's Standard (at the time), to include curved elements; most notably used in MapGuide.[3]
[edit] See also
[edit] References
- ^ GIS and Spatial Extensions with MySQL
- ^ http://postgis.refractions.net/docs/ST_GeomFromEWKT.html
- ^ http://www.osgeo.org/files/mapguide/docs/2.0/da/dc0/group___agf_text.htm