Functions in this section return properties of
Polygon or MultiPolygon
values.
ST_Area()andArea()are synonyms. For more information, see the description ofST_Area().Area()is deprecated; expect it to be removed in a future MySQL release. UseST_Area()instead.ST_Centroid()andCentroid()are synonyms. For more information, see the description ofST_Centroid().Centroid()is deprecated; expect it to be removed in a future MySQL release. UseST_Centroid()instead.ST_ExteriorRing()andExteriorRing()are synonyms. For more information, see the description ofST_ExteriorRing().ExteriorRing()is deprecated; expect it to be removed in a future MySQL release. UseST_ExteriorRing()instead.ST_InteriorRingN()andInteriorRingN()are synonyms. For more information, see the description ofST_InteriorRingN().InteriorRingN()is deprecated; expect it to be removed in a future MySQL release. UseST_InteriorRingN()instead.ST_NumInteriorRings()andNumInteriorRings()are synonyms. For more information, see the description ofST_NumInteriorRings().NumInteriorRings()is deprecated; expect it to be removed in a future MySQL release. UseST_NumInteriorRings()instead.Returns a double-precision number indicating the area of the
PolygonorMultiPolygonargument, as measured in its spatial reference system. For arguments of dimension 0 or 1, the result is 0. If the argument is an empty geometry the return value is 0. If the argument isNULLthe return value isNULL.The result is the sum of the area values of all components for a geometry collection. If a geometry collection is empty, its area is returned as 0.
mysql> SET @poly = 'Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))'; mysql> SELECT ST_Area(ST_GeomFromText(@poly)); +---------------------------------+ | ST_Area(ST_GeomFromText(@poly)) | +---------------------------------+ | 4 | +---------------------------------+ mysql> SET @mpoly = 'MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))'; mysql> SELECT ST_Area(ST_GeomFromText(@mpoly)); +----------------------------------+ | ST_Area(ST_GeomFromText(@mpoly)) | +----------------------------------+ | 8 | +----------------------------------+Returns the mathematical centroid for the
PolygonorMultiPolygonargument as aPoint. The result is not guaranteed to be on theMultiPolygon. If the argument isNULLor an empty geometry, the return value isNULL.This function processes geometry collections by computing the centroid point for components of highest dimension in the collection. Such components are extracted and made into a single
MultiPolygon,MultiLineString, orMultiPointfor centroid computation. If the argument is an empty geometry collection, the return value isNULL.mysql> SET @poly = ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))'); mysql> SELECT ST_GeometryType(@poly),ST_AsText(ST_Centroid(@poly)); +------------------------+--------------------------------------------+ | ST_GeometryType(@poly) | ST_AsText(ST_Centroid(@poly)) | +------------------------+--------------------------------------------+ | POLYGON | POINT(4.958333333333333 4.958333333333333) | +------------------------+--------------------------------------------+ST_Centroid()andCentroid()are synonyms.Returns the exterior ring of the
Polygonvaluepolyas aLineString. If the argument isNULLor an empty geometry, the return value isNULL.mysql> SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'; mysql> SELECT ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly))); +----------------------------------------------------+ | ST_AsText(ST_ExteriorRing(ST_GeomFromText(@poly))) | +----------------------------------------------------+ | LINESTRING(0 0,0 3,3 3,3 0,0 0) | +----------------------------------------------------+ST_ExteriorRing()andExteriorRing()are synonyms.Returns the
N-th interior ring for thePolygonvaluepolyas aLineString. Rings are numbered beginning with 1. If the argument isNULLor an empty geometry, the return value isNULL.mysql> SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'; mysql> SELECT ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1)); +-------------------------------------------------------+ | ST_AsText(ST_InteriorRingN(ST_GeomFromText(@poly),1)) | +-------------------------------------------------------+ | LINESTRING(1 1,1 2,2 2,2 1,1 1) | +-------------------------------------------------------+ST_InteriorRingN()andInteriorRingN()are synonyms.ST_NumInteriorRing(,poly)ST_NumInteriorRings(poly)Returns the number of interior rings in the
Polygonvaluepoly. If the argument isNULLor an empty geometry, the return value isNULL.mysql> SET @poly = 'Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'; mysql> SELECT ST_NumInteriorRings(ST_GeomFromText(@poly)); +---------------------------------------------+ | ST_NumInteriorRings(ST_GeomFromText(@poly)) | +---------------------------------------------+ | 1 | +---------------------------------------------+ST_NumInteriorRing(),ST_NumInteriorRings(), andNumInteriorRings()are synonyms.