Well-Known Text (WKT) Format
The Well-Known Text (WKT) representation of Geometry is designed to exchange geometry data in ASCII form. For a Backus-Naur grammar that specifies the formal production rules for writing WKT values, see the OpenGIS specification document referenced in , "Spatial Extensions".
Examples of WKT representations of geometry objects:
- A
Point:POINT(15 20)
Note that point coordinates are specified with no separating comma. This differs from the syntax for the SQL
POINT()function, which requires a comma between the coordinates. Take care to use the syntax appropriate to the context of a given spatial operation. For example, the following statements both extract the X-coordinate from aPointobject. The first produces the object directly using thePOINT()function. The second uses a WKT representation converted to aPointwithGeomFromText().mysql>
SELECT X(POINT(15, 20));+------------------+ | X(POINT(15, 20)) | +------------------+ | 15 | +------------------+ mysql>SELECT X(GeomFromText('POINT(15 20)'));+---------------------------------+ | X(GeomFromText('POINT(15 20)')) | +---------------------------------+ | 15 | +---------------------------------+ - A
LineStringwith four points:LINESTRING(0 0, 10 10, 20 25, 50 60)
Note that point coordinate pairs are separated by commas.
- A
Polygonwith one exterior ring and one interior ring:POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))
- A
MultiPointwith threePointvalues:MULTIPOINT(0 0, 20 20, 60 60)
- A
MultiLineStringwith twoLineStringvalues:MULTILINESTRING((10 10, 20 20), (15 15, 30 15))
- A
MultiPolygonwith twoPolygonvalues:MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((5 5,7 5,7 7,5 7, 5 5)))
- A
GeometryCollectionconsisting of twoPointvalues and oneLineString: