top of page
CerebroSQL

MySQL: 

ST_ENVELOPE

ST_Envelope(g)

Returns the minimum bounding rectangle (MBR) for the geometry value g.
The result is returned as a Polygon value that is defined by the corner
points of the bounding box:

POLYGON((MINX MINY, MAXX MINY, MAXX MAXY, MINX MAXY, MINX MINY))

mysql> SELECT ST_AsText(ST_Envelope(ST_GeomFromText('LineString(1 1,2 2)')));
+----------------------------------------------------------------+
| ST_AsText(ST_Envelope(ST_GeomFromText('LineString(1 1,2 2)'))) |
+----------------------------------------------------------------+
| POLYGON((1 1,2 1,2 2,1 2,1 1)) |
+----------------------------------------------------------------+

If the argument is a point or a vertical or horizontal line segment,
ST_Envelope() returns the point or the line segment as its MBR rather
than returning an invalid polygon:

mysql> SELECT ST_AsText(ST_Envelope(ST_GeomFromText('LineString(1 1,1 2)')));
+----------------------------------------------------------------+
| ST_AsText(ST_Envelope(ST_GeomFromText('LineString(1 1,1 2)'))) |
+----------------------------------------------------------------+
| LINESTRING(1 1,1 2) |
+----------------------------------------------------------------+

ST_Envelope() handles its arguments as described in the introduction to
this section, with this exception:

o If the geometry has an SRID value for a geographic spatial reference
system (SRS), an ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference
.html#error_er_not_implemented_for_geographic_srs) error occurs.

URL: https://dev.mysql.com/doc/refman/8.0/en/gis-general-property-functions.html

Example

bottom of page