All pages
Powered by GitBook
1 of 11

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Polygon Properties

Learn about POLYGON properties in MariaDB Server. This section details SQL functions for retrieving attributes of polygonal spatial objects, such as area, perimeter, and the number of rings.

CENTROID

Synonym for ST_CENTROID. Returns the mathematical centroid of the Polygon or MultiPolygon as a Point geometry.

A synonym for ST_CENTROID.

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

NumInteriorRings

Synonym for ST_NumInteriorRings. Returns the number of interior rings in a Polygon geometry.

A synonym for ST_NumInteriorRings.

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

InteriorRingN

Synonym for ST_InteriorRingN. Returns the N-th interior ring of a Polygon as a LineString.

A synonym for .

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

AREA

Synonym for ST_AREA. Returns the double-precision area of the Polygon or MultiPolygon, calculated in its spatial reference system.

A synonym for .

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

ExteriorRing

Synonym for ST_ExteriorRing. Returns the exterior ring of a Polygon as a LineString.

A synonym for .

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

ST_ExteriorRing

Returns the exterior ring of a Polygon. This function extracts the outer boundary of the polygon as a LineString geometry.

Syntax

Description

Returns the exterior ring of the Polygon value poly

as a LineString.

ST_ExteriorRing() and ExteriorRing() are synonyms.

Examples

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

ST_ExteriorRing(poly)
ExteriorRing(poly)
SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';

SELECT AsText(ExteriorRing(GeomFromText(@poly)));
+-------------------------------------------+
| AsText(ExteriorRing(GeomFromText(@poly))) |
+-------------------------------------------+
| LINESTRING(0 0,0 3,3 3,3 0,0 0)           |
+-------------------------------------------+
ST_InteriorRingN
ST_AREA
ST_ExteriorRing

ST_NumInteriorRings

Returns the count of interior rings in a Polygon. This function calculates the total number of inner holes within the polygon.

Syntax

ST_NumInteriorRings(poly)
NumInteriorRings(poly)

Description

Returns an integer containing the number of interior rings in the Polygon value poly.

Note that according the OpenGIS standard, a should have exactly one ExteriorRing and all other rings should lie within that ExteriorRing and thus be the InteriorRings. Practically, however, some systems, including MariaDB's, permit polygons to have several 'ExteriorRings'. In the case of there being multiple, non-overlapping exterior rings ST_NumInteriorRings() will return 1.

ST_NumInteriorRings() and NumInteriorRings() are synonyms.

Examples

Non-overlapping 'polygon':

This page is licensed: GPLv2, originally from

SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';

SELECT NumInteriorRings(GeomFromText(@poly));
+---------------------------------------+
| NumInteriorRings(GeomFromText(@poly)) |
+---------------------------------------+
|                                     1 |
+---------------------------------------+
POLYGON
fill_help_tables.sql

ST_CENTROID

Returns the centroid of a Polygon or MultiPolygon. The result is a Point geometry representing the mathematical center of mass.

Syntax

ST_Centroid(mpoly)
Centroid(mpoly)

Description

Returns a point reflecting the mathematical centroid (geometric center) for the MultiPolygon mpoly. The resulting point will not necessarily be on the MultiPolygon.

ST_Centroid() and Centroid() are synonyms.

Examples

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

SELECT ST_NumInteriorRings(ST_PolyFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),
  (-1 -1,-5 -1,-5 -5,-1 -5,-1 -1))')) AS NumInteriorRings;
+------------------+
| NumInteriorRings |
+------------------+
|                1 |
+------------------+
SET @poly = ST_GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))');
SELECT ST_AsText(ST_Centroid(@poly)) AS center;
+--------------+
| center       |
+--------------+
| POINT(10 10) |
+--------------+

ST_InteriorRingN

Returns the N-th interior ring of a Polygon. This function retrieves a specific inner hole of the polygon as a LineString.

Syntax

ST_InteriorRingN(poly,N)
InteriorRingN(poly,N)

Description

Returns the N-th interior ring for the Polygon value poly as a LineString. Rings are numbered beginning with 1.

ST_InteriorRingN() and InteriorRingN() are synonyms.

Examples

This page is licensed: GPLv2, originally from

SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))';

SELECT AsText(InteriorRingN(GeomFromText(@poly),1));
+----------------------------------------------+
| AsText(InteriorRingN(GeomFromText(@poly),1)) |
+----------------------------------------------+
| LINESTRING(1 1,1 2,2 2,2 1,1 1)              |
+----------------------------------------------+
fill_help_tables.sql

ST_AREA

Returns the area of a Polygon or MultiPolygon. The result is a double-precision number measured in the geometry's spatial reference units.

Syntax

ST_Area(poly)
Area(poly)

Description

Returns as a double-precision number the area of the Polygon value poly, as measured in its spatial reference system.

ST_Area() and Area() are synonyms.

Examples

This page is licensed: GPLv2, originally from

SET @poly = 'Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))';

SELECT Area(GeomFromText(@poly));
+---------------------------+
| Area(GeomFromText(@poly)) |
+---------------------------+
|                         4 |
+---------------------------+
fill_help_tables.sql