All pages
Powered by GitBook
1 of 36

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

WKT

Learn about Well-Known Text (WKT) in MariaDB Server. This section details how to represent and store geometric data in a text format, essential for human-readable spatial data exchange.

LineStringFromText

Synonym for ST_LineFromText. Constructs a LineString value from its WKT representation and an optional SRID.

A synonym for ST_LineFromText.

This page is licensed: CC BY-SA / Gnu FDL

AsText

Synonym for ST_AsText. Converts a geometry value from its internal format to its Well-Known Text (WKT) representation.

A synonym for ST_AsText().

This page is licensed: CC BY-SA / Gnu FDL

WKT Definition

Understand the Well-Known Text (WKT) format. This section describes the standard ASCII representation for exchanging geometric data.

Description

The Well-Known Text (WKT) representation of Geometry is designed to exchange geometry data in ASCII form. Examples of the basic geometry types include:

Geometry Types

AsWKT

Synonym for ST_AsText. Converts a geometry value from its internal format to its Well-Known Text (WKT) representation.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

PolyFromText

Synonym for ST_PolyFromText. Constructs a Polygon value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

LineFromText

Synonym for ST_LineFromText. Constructs a LineString value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

MultiLineStringFromText

Synonym for ST_MultiLineStringFromText. Constructs a MultiLineString value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

See Also

  • Geometry Types

This page is licensed: GPLv2, originally from fill_help_tables.sql

POINT

LINESTRING

ST_AsText()
ST_PolyFromText
ST_LineFromText
MLineFromText

GeometryFromText

Synonym for ST_GeomFromText. Constructs a geometry value of any type from its WKT representation and an optional SRID.

A synonym for ST_GeomFromText.

This page is licensed: CC BY-SA / Gnu FDL

MultiPolygonFromText

Synonym for ST_MultiPolygonFromText. Constructs a MultiPolygon value from its WKT representation and an optional SRID.

A synonym for MPolyFromText.

This page is licensed: CC BY-SA / Gnu FDL

GeomFromText

Synonym for ST_GeomFromText. Constructs a geometry value of any type from its WKT representation and an optional SRID.

A synonym for ST_GeomFromText.

This page is licensed: CC BY-SA / Gnu FDL

GeometryCollectionFromText

Synonym for ST_GeomCollFromText. Constructs a GeometryCollection value from its WKT representation and an optional SRID.

A synonym for ST_GeomCollFromText.

This page is licensed: CC BY-SA / Gnu FDL

GeomCollFromText

Synonym for ST_GeomCollFromText. Constructs a GeometryCollection value from its WKT representation and an optional SRID.

A synonym for ST_GeomCollFromText.

This page is licensed: CC BY-SA / Gnu FDL

MLineFromText

Synonym for ST_MultiLineStringFromText. Constructs a MultiLineString value from its WKT representation and an optional SRID.

Syntax

MLineFromText(wkt[,srid])
MultiLineStringFromText(wkt[,srid])

Description

Constructs a MULTILINESTRING value using its WKT representation and SRID.

MLineFromText() and MultiLineStringFromText() are synonyms.

Examples

This page is licensed: GPLv2, originally from

MultiPointFromText

Synonym for ST_MultiPointFromText. Constructs a MultiPoint value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

MPolyFromText

Synonym for ST_MultiPolygonFromText. Constructs a MultiPolygon value from its WKT representation and an optional SRID.

Syntax

Description

Constructs a value using its representation and .

MPointFromText

Synonym for ST_MultiPointFromText. Constructs a MultiPoint value from its WKT representation and an optional SRID.

Syntax

Description

Constructs a value using its representation and .

MPolyFromText() and MultiPolygonFromText() are synonyms.

Examples

This page is licensed: GPLv2, originally from fill_help_tables.sql

MPolyFromText(wkt[,srid])
MultiPolygonFromText(wkt[,srid])
MULTIPOLYGON
WKT
SRID
MPointFromText() and MultiPointFromText() are synonyms.

Examples

This page is licensed: GPLv2, originally from fill_help_tables.sql

MPointFromText(wkt[,srid])
MultiPointFromText(wkt[,srid])
MULTIPOINT
WKT
SRID
CREATE TABLE gis_multi_line (g MULTILINESTRING);
SHOW FIELDS FROM gis_multi_line;
INSERT INTO gis_multi_line VALUES
    (MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
    (MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
    (MLineFromWKB(AsWKB(MultiLineString(
      LineString(Point(1, 2), Point(3, 5)), 
      LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
fill_help_tables.sql
POLYGON
MULTIPOINT
MULTILINESTRING
MULTIPOLYGON
GEOMETRYCOLLECTION
GEOMETRY
MPointFromText

PointFromText

Synonym for ST_PointFromText. Constructs a Point value from its WKT representation and an optional SRID.

A synonym for ST_PointFromText.

This page is licensed: CC BY-SA / Gnu FDL

ST_GeomCollFromText

Constructs a GeometryCollection value from its WKB representation and an optional SRID.

Syntax

Description

Constructs a value using its representation and .

ST_GeometryFromText

Synonym for ST_GeomFromText. Constructs a geometry value of any type from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

ST_MLineFromText

Synonym for ST_MultiLineStringFromText. Constructs a MultiLineString value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

ST_MPolyFromText

Synonym for ST_MultiPointFromText. Constructs a MultiPoint value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

ST_PolygonFromText

Synonym for ST_PolyFromText. Constructs a Polygon value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

ST_MultiPolygonFromText

Constructs a MultiPolygon value using its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

CREATE TABLE gis_multi_polygon  (g MULTIPOLYGON);
SHOW FIELDS FROM gis_multi_polygon;
INSERT INTO gis_multi_polygon VALUES
    (MultiPolygonFromText('MULTIPOLYGON(
       ((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),
       ((59 18,67 18,67 13,59 13,59 18)))')),
    (MPolyFromText('MULTIPOLYGON(
       ((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),
       ((59 18,67 18,67 13,59 13,59 18)))')),
    (MPolyFromWKB(AsWKB(MultiPolygon(Polygon(
       LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
CREATE TABLE gis_multi_point (g MULTIPOINT);
SHOW FIELDS FROM gis_multi_point;
INSERT INTO gis_multi_point VALUES
    (MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
    (MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
    (MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));

ST_ASWKT

Synonym for ST_AsText. Converts a geometry value from its internal format to its Well-Known Text (WKT) representation.

A synonym for ST_ASTEXT().

This page is licensed: CC BY-SA / Gnu FDL

ST_GeomFromText
ST_GeomFromText
ST_GeomFromText
ST_PolyFromText
ST_GeomFromText

ST_LineStringFromText

Synonym for ST_LineFromText. Constructs a LineString value from its WKT representation and an optional SRID.

A synonym for ST_LineFromText.

This page is licensed: CC BY-SA / Gnu FDL

ST_MultiPointFromText

Constructs a MultiPoint value using its WKT representation and an optional SRID.

A synonym for ST_GeomFromText.

This page is licensed: CC BY-SA / Gnu FDL

ST_GeometryCollectionFromText

Synonym for ST_GeomCollFromText. Constructs a GeometryCollection value from its WKT representation and an optional SRID.

A synonym for ST_GeomCollFromText.

This page is licensed: CC BY-SA / Gnu FDL

PolygonFromText

Synonym for ST_PolyFromText. Constructs a Polygon value from its WKT representation and an optional SRID.

A synonym for ST_PolyFromText.

This page is licensed: CC BY-SA / Gnu FDL

ST_GeomCollFromText(), ST_GeometryCollectionFromText(), GeomCollFromText() and GeometryCollectionFromText() are all synonyms.

Example

This page is licensed: GPLv2, originally from fill_help_tables.sql

ST_GeomCollFromText(wkt[,srid])
ST_GeometryCollectionFromText(wkt[,srid])
GeomCollFromText(wkt[,srid])
GeometryCollectionFromText(wkt[,srid])
GEOMETRYCOLLECTION
WKT
SRID
CREATE TABLE gis_geometrycollection  (g GEOMETRYCOLLECTION);
SHOW FIELDS FROM gis_geometrycollection;
INSERT INTO gis_geometrycollection VALUES
    (GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
    (GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),
    (GeomFromText('GeometryCollection()')),
    (GeomFromText('GeometryCollection EMPTY'));

ST_LineFromText

Constructs a LineString value using its WKT representation and an optional SRID.

Syntax

ST_LineFromText(wkt[,srid])
ST_LineStringFromText(wkt[,srid])
LineFromText(wkt[,srid])
LineStringFromText(wkt[,srid])

Description

Constructs a LINESTRING value using its WKT representation and SRID.

ST_LineFromText(), ST_LineStringFromText(), ST_LineFromText() and ST_LineStringFromText() are all synonyms.

Examples

This page is licensed: GPLv2, originally from

ST_AsText

Converts a value in internal geometry format to its WKT representation and returns the string result.

Syntax

ST_AsText(g)
AsText(g)
ST_AsWKT(g)
AsWKT(g)

Description

Converts a value in internal geometry format to its WKT representation and returns the string result.

ST_AsText(), AsText(), ST_AsWKT() and AsWKT() are all synonyms.

Examples

This page is licensed: GPLv2, originally from

ST_MPointFromText

Synonym for ST_MultiLineStringFromText. Constructs a MultiLineString value from its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

ST_GeomFromText

Constructs a geometry value of any type using its WKT representation and an optional SRID.

Syntax

Description

Constructs a geometry value of any type using its representation and .

ST_PointFromText

Constructs a Point value using its WKT representation and an optional SRID.

Syntax

Description

Constructs a value using its representation and .

ST_PolyFromText

Constructs a Polygon value using its WKT representation and an optional SRID.

Syntax

Description

Constructs a value using its representation and .

ST_MultiLineStringFromText

Constructs a MultiLineString value using its WKT representation and an optional SRID.

A synonym for .

This page is licensed: CC BY-SA / Gnu FDL

ST_GeomFromText
ST_GeomFromText
CREATE TABLE gis_line  (g LINESTRING);
SHOW FIELDS FROM gis_line;
INSERT INTO gis_line VALUES
    (LineFromText('LINESTRING(0 0,0 10,10 0)')),
    (LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
    (LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
fill_help_tables.sql
SET @g = 'LineString(1 1,4 4,6 6)';

SELECT ST_AsText(ST_GeomFromText(@g));
+--------------------------------+
| ST_AsText(ST_GeomFromText(@g)) |
+--------------------------------+
| LINESTRING(1 1,4 4,6 6)        |
+--------------------------------+
fill_help_tables.sql
GeomFromText(), GeometryFromText(), ST_GeomFromText(), ST_GeometryFromText(), ST_MultiLineStringFromText, ST_MLineFromText, ST_MultiPolyFromText and ST_MPolygonFromText are all synonyms.

Example

This page is licensed: GPLv2, originally from fill_help_tables.sql

ST_GeomFromText(wkt[,srid])
ST_GeometryFromText(wkt[,srid])
GeomFromText(wkt[,srid])
GeometryFromText(wkt[,srid])

ST_MultiLineStringFromText(wkt[,srid])
ST_MLineFromText(wkt[,srid])
ST_MPointFromText(wkt[,srid])
ST_MultiPointFromText(wkt[,srid])
WKT
SRID
ST_PointFromText() and PointFromText() are synonyms.

Examples

This page is licensed: GPLv2, originally from fill_help_tables.sql

ST_PointFromText(wkt[,srid])
PointFromText(wkt[,srid])
POINT
WKT
SRID
ST_PolyFromText(), ST_PolygonFromText(), PolyFromText() and ST_PolygonFromText() are all synonyms.

Examples

This page is licensed: GPLv2, originally from fill_help_tables.sql

ST_PolyFromText(wkt[,srid])
ST_PolygonFromText(wkt[,srid])
PolyFromText(wkt[,srid])
PolygonFromText(wkt[,srid])
POLYGON
WKT
SRID
SET @g = ST_GEOMFROMTEXT('POLYGON((1 1,1 5,4 9,6 9,9 3,7 2,1 1))');
CREATE TABLE gis_point  (g POINT);
SHOW FIELDS FROM gis_point;
INSERT INTO gis_point VALUES
    (PointFromText('POINT(10 10)')),
    (PointFromText('POINT(20 10)')),
    (PointFromText('POINT(20 20)')),
    (PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
CREATE TABLE gis_polygon   (g POLYGON);
INSERT INTO gis_polygon VALUES
    (PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
    (PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'));