content_image/763138.jpg
• ST_Centroid({ poly | mpoly }) 

Returns the mathematical centroid for the Polygon  or MultiPolygon  argument as a Point . The result is not guaranteed to be on the MultiPolygon . 

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 , or MultiPoint  for centroid computation. 

ST_Centroid()  handles its arguments as described in the introduction to this section, with these exceptions: 

•The return value is NULL  for the additional condition that the argument is an empty geometry collection. 

•If the geometry has an SRID value for a geographic spatial reference system (SRS), an ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS  error occurs. 

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)); 

<img src='content_image/763138.jpg'>

• ST_ExteriorRing( poly ) 

Returns the exterior ring of the Polygon  value poly  as a LineString . 

ST_ExteriorRing()  handles its arguments as described in the introduction to this section. 

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_InteriorRingN( poly , N ) 

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

ST_InteriorRingN()  handles its arguments as described in the introduction to this section. 

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) | +-------------------------------------------------------+ 

