ST_Envelope
ST_Envelope returns the minimum bounding box of the input geometry, as follows:
If the input geometry is empty, the returned geometry is a copy of the input geometry.
If the minimum bounding box of the input geometry degenerates to a point, the returned geometry is a point.
If the minimum bounding box of the input geometry is onedimensional, a twopoint linestring is returned.
If none of the preceding is true, the function returns a clockwiseoriented polygon whose vertices are the corners of the minimum bounding box.
The spatial reference system identifier (SRID) of the returned geometry is the same as that of the input geometry.
For all nonempty input, the function operates on the 2D projection of the input geometry.
Syntax
ST_Envelope(geom)
Arguments
 geom

A value of data type
GEOMETRY
or an expression that evaluates to aGEOMETRY
type.
Return type
GEOMETRY
If geom is null, then null is returned.
Examples
The following SQL converts a wellknown text (WKT) representation of a fourpoint
LINESTRING
to a GEOMETRY
object and returns a polygon whose vertices whose corners are the minimum bounding box.
SELECT ST_AsText(ST_Envelope(ST_GeomFromText('GEOMETRYCOLLECTION(POLYGON((0 0,10 0,0 10,0 0)),LINESTRING(20 10,20 0,10 0))')));
st_astext

POLYGON((0 0,0 10,20 10,20 0,0 0))