All pages
Powered by GitBook
1 of 24

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Geometry Properties

Learn about geometry properties. This section details SQL functions for retrieving attributes of spatial objects, such as area, length, and bounding box, essential for geospatial analysis.

BOUNDARY

Synonym for ST_BOUNDARY. Returns a geometry representing the closure of the combinatorial boundary of the geometry value.

A synonym for ST_BOUNDARY.

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

DIMENSION

Synonym for ST_DIMENSION. Returns the inherent dimension of a geometry object (0 for Point, 1 for LineString, 2 for Polygon).

A synonym for .

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

ST_DIMENSION

ST_ENVELOPE

Returns the Minimum Bounding Rectangle (MBR) for the geometry value. The result is returned as a Polygon defined by the corner points.

Syntax

ST_ENVELOPE(g)
ENVELOPE(g)

Description

Returns the Minimum Bounding Rectangle (MBR) for the geometry value g. The result is returned as a Polygon value.

The polygon is defined by the corner points of the bounding box:

ST_ENVELOPE() and ENVELOPE() are synonyms.

Examples

This page is licensed: GPLv2, originally from

POLYGON((MINX MINY, MAXX MINY, MAXX MAXY, MINX MAXY, MINX MINY))
SELECT AsText(ST_ENVELOPE(GeomFromText('LineString(1 1,4 4)')));
+----------------------------------------------------------+
| AsText(ST_ENVELOPE(GeomFromText('LineString(1 1,4 4)'))) |
+----------------------------------------------------------+
| POLYGON((1 1,4 1,4 4,1 4,1 1))                           |
+----------------------------------------------------------+
fill_help_tables.sql

NumGeometries

Synonym for ST_NUMGEOMETRIES. Returns the number of geometries contained in a GeometryCollection.

A synonym for ST_NumGeometries.

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

IsSimple

Synonym for ST_ISSIMPLE. Checks if a geometry is simple, meaning it has no anomalous geometric points like self-intersections.

A synonym for ST_IsSImple.

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

ST_GEOMETRYTYPE

Returns the name of the geometry type (e.g., 'POINT', 'LINESTRING', 'POLYGON') for the given geometry instance.

Syntax

Description

Returns as a string the name of the geometry type of which the geometry instance g

is a member. The name corresponds to one of the instantiable Geometry subclasses.

ST_GeometryType() and GeometryType() are synonyms.

Examples

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

ST_GeometryType(g)
GeometryType(g)
SELECT GeometryType(GeomFromText('POINT(1 1)'));
+------------------------------------------+
| GeometryType(GeomFromText('POINT(1 1)')) |
+------------------------------------------+
| POINT                                    |
+------------------------------------------+

ST_BOUNDARY

Returns the combinatorial boundary of a geometry. For a Polygon, this is the line string defining the boundary.

Syntax

ST_BOUNDARY(g)
BOUNDARY(g)

Description

Returns a geometry that is the closure of the combinatorial boundary of the geometry value g.

BOUNDARY() is a synonym.

Examples

This page is licensed: GPLv2, originally from

IsRing

Synonym for ST_ISRING. Checks if a LineString is a ring, meaning it is both closed and simple.

A synonym for ST_IsRing.

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

ST_IsSimple

Checks if the geometry is simple (no self-intersections or anomalous points). Returns 1 if simple, 0 otherwise.

Syntax

ST_IsSimple(g)
IsSimple(g)

Description

Returns true if the given Geometry has no anomalous geometric points, false if it does, or NULL if given a NULL value.

ST_IsSimple() and IsSimple() are synonyms.

Examples

A POINT is always simple.

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

ENVELOPE

Synonym for ST_ENVELOPE. Returns the Minimum Bounding Rectangle (MBR) for the given geometry as a Polygon.

A synonym for .

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

ST_IsRing

Checks if the LineString is a ring. Returns 1 if the LineString is both closed (start equals end) and simple (no self-intersection).

Syntax

Description

Returns true if a given is a ring, that is, both and . A simple curve does not pass through the same point more than once. However, see

ST_ISCLOSED

Returns 1 if the LineString is closed (start and end points are the same), 0 if not, and NULL if the argument is NULL.

Syntax

Description

Returns 1 if a given start and end points are the same, or 0 if they are not the same.

ST_ENVELOPE

GeometryN

Synonym for ST_GEOMETRYN. Returns the N-th geometry from a GeometryCollection, numbered starting from 1.

A synonym for ST_GeometryN.

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

SELECT ST_AsText(ST_Boundary(ST_GeomFromText('LINESTRING(3 3,0 0, -3 3)')));
+----------------------------------------------------------------------+
| ST_AsText(ST_Boundary(ST_GeomFromText('LINESTRING(3 3,0 0, -3 3)'))) |
+----------------------------------------------------------------------+
| MULTIPOINT(3 3,-3 3)                                                 |
+----------------------------------------------------------------------+

SELECT ST_AsText(ST_Boundary(ST_GeomFromText('POLYGON((3 3,0 0, -3 3, 3 3))')));
+--------------------------------------------------------------------------+
| ST_AsText(ST_Boundary(ST_GeomFromText('POLYGON((3 3,0 0, -3 3, 3 3))'))) |
+--------------------------------------------------------------------------+
| LINESTRING(3 3,0 0,-3 3,3 3)                                             |
+--------------------------------------------------------------------------+
fill_help_tables.sql
SET @g = 'Point(1 2)';

SELECT ST_ISSIMPLE(GEOMFROMTEXT(@g));
+-------------------------------+
| ST_ISSIMPLE(GEOMFROMTEXT(@g)) |
+-------------------------------+
|                             1 |
+-------------------------------+
.

St_IsRing() and IsRing() are synonyms.

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

ST_IsRing(g)
IsRing(g)
LINESTRING
ST_IsClosed
ST_IsSimple
MDEV-7510
ST_IsClosed() and IsClosed() are synonyms.

Examples

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

ST_IsClosed(g)
IsClosed(g)
LINESTRING's
SET @ls = 'LineString(0 0, 0 4, 4 4, 0 0)';
SELECT ST_ISCLOSED(GEOMFROMTEXT(@ls));
+--------------------------------+
| ST_ISCLOSED(GEOMFROMTEXT(@ls)) |
+--------------------------------+
|                              1 |
+--------------------------------+

SET @ls = 'LineString(0 0, 0 4, 4 4, 0 1)';
SELECT ST_ISCLOSED(GEOMFROMTEXT(@ls));
+--------------------------------+
| ST_ISCLOSED(GEOMFROMTEXT(@ls)) |
+--------------------------------+
|                              0 |
+--------------------------------+

ST_GEOMETRYN

Returns the N-th geometry in a GeometryCollection. Geometries are numbered beginning with 1.

Syntax

ST_GeometryN(gc,N)
GeometryN(gc,N)

Description

Returns the N-th geometry in the GeometryCollection gc. Geometries are numbered beginning with 1.

ST_GeometryN() and GeometryN() are synonyms.

Example

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

ST_DIMENSION

Returns the inherent dimension of the geometry value. Returns 0 for points, 1 for linear geometries, and 2 for surface geometries.

Syntax

ST_Dimension(g)
Dimension(g)

Description

Returns the inherent dimension of the geometry value g. The result can be

Dimension
Definition

ST_Dimension() and Dimension() are synonyms.

Examples

This page is licensed: GPLv2, originally from

ST_NUMGEOMETRIES

Returns the number of geometries in a GeometryCollection. Returns NULL if the argument is not a GeometryCollection.

Syntax

ST_NumGeometries(gc)
NumGeometries(gc)

Description

Returns the number of geometries in the GeometryCollection gc.

ST_NumGeometries() and NumGeometries() are synonyms.

Example

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

ST_SRID

Returns the Spatial Reference Identifier (SRID) for the geometry. This integer represents the coordinate system used.

Syntax

ST_SRID(g)
SRID(g)

Description

Returns an integer indicating the Spatial Reference System ID for the geometry value g.

In MariaDB, the SRID value is just an integer associated with the geometry value. All calculations are done assuming Euclidean (planar) geometry.

ST_SRID() and SRID() are synonyms.

Examples

This page is licensed: GPLv2, originally from

SRID

Synonym for ST_SRID. Returns the Spatial Reference Identifier (SRID) integer associated with the geometry.

A synonym for .

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

ST_SRID

IsClosed

Synonym for ST_ISCLOSED. Checks if a LineString's start and end points are the same (closed).

A synonym for ST_IsClosed.

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

GeometryType

Synonym for ST_GEOMETRYTYPE. Returns the name of the geometry type (e.g., 'POINT') of the geometry instance.

A synonym for ST_GeometryType.

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

SET @gc = 'GeometryCollection(Point(1 1),LineString(12 14, 9 11))';

SELECT AsText(GeometryN(GeomFromText(@gc),1));
+----------------------------------------+
| AsText(GeometryN(GeomFromText(@gc),1)) |
+----------------------------------------+
| POINT(1 1)                             |
+----------------------------------------+

-1

empty geometry

0

geometry with no length or area

1

geometry with no area but nonzero length

2

geometry with nonzero area

fill_help_tables.sql
SET @gc = 'GeometryCollection(Point(1 1),LineString(2 2, 3 3))';

SELECT NUMGEOMETRIES(GeomFromText(@gc));
+----------------------------------+
| NUMGEOMETRIES(GeomFromText(@gc)) |
+----------------------------------+
|                                2 |
+----------------------------------+
SELECT SRID(GeomFromText('LineString(1 1,2 2)',101));
+-----------------------------------------------+
| SRID(GeomFromText('LineString(1 1,2 2)',101)) |
+-----------------------------------------------+
|                                           101 |
+-----------------------------------------------+
fill_help_tables.sql
SELECT Dimension(GeomFromText('LineString(1 1,2 2)'));
+------------------------------------------------+
| Dimension(GeomFromText('LineString(1 1,2 2)')) |
+------------------------------------------------+
|                                              1 |
+------------------------------------------------+

ST_ISEMPTY

Checks if a geometry is empty. Returns 1 if the geometry contains no points, and 0 otherwise.

Syntax

ST_IsEmpty(g)
IsEmpty(g)

Description

IsEmpty is a function defined by the OpenGIS specification, but is not fully implemented by MariaDB or MySQL.

Since MariaDB and MySQL do not support GIS EMPTY values such as POINT EMPTY, as implemented it simply returns 1 if the geometry value g is invalid, 0 if it is valid, and NULL if the argument is NULL.

ST_IsEmpty() and IsEmpty() are synonyms.

This page is licensed: GPLv2, originally from

fill_help_tables.sql

IsEmpty

Synonym for ST_ISEMPTY. Checks if a geometry is empty (contains no point sets). Returns 1 if empty, 0 otherwise.

A synonym for ST_IsEmpty.

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

ST_RELATE

Tests if two geometries are spatially related according to a given DE-9IM intersection matrix pattern.

Syntax

ST_Relate(g1, g2, i)

Description

Returns true if Geometry g1 is spatially related to Geometryg2 by testing for intersections between the interior, boundary and exterior of the two geometries as specified by the values in intersection matrix pattern i.

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