14 February 2018

habitatArea

My solution:
CREATE PROCEDURE habitatArea() 
BEGIN 
  SELECT ST_Area(ST_ConvexHull(ST_GeomFromText(m.g))) AS area 
  FROM   places, 
         (SELECT CONCAT("MULTIPOINT(", i.str, ")") AS g 
          FROM   (SELECT GROUP_CONCAT(x, " ", y) AS str 
                  FROM   places) i) AS m 
  LIMIT  1; 
END 

I used
+----------------------------------+
| ST_Area(ST_GeomFromText(@mpoly)) |
+----------------------------------+
Source: MySQL Reference Manual - 12.15.7.4 Polygon and MultiPolygon Property Functions.

and
+-----------------------------------------------+
| ST_ConvexHull(ST_GeomFromText(@mpoly))        |
+-----------------------------------------------+
Source: MySQL Reference Manual - 12.15.8 Spatial Operator Functions.