This topic describes the ST_Envelope function. This function returns the bounding box of the input geometry object.

Syntax

geometry  ST_Envelope(geometry  g1);

Parameters

Parameter Description
g1 The geometry object that you want to specify.

Description

  • The value of the bounding box is in the FLOAT8 data type.
  • A bounding box is represented as a polygon object and the bounding box is defined by the corner points of the polygon object. Format of corner points: (MINX,MINY),(MINX,MAXY),(MAXX,MAXY),(MAXX,MINY),(MINX,MINY).
  • If you specify a vertical line or a point, this function returns a geometry object of a lower dimension than a polygon object, such as a point object or a LineString object. This is a degenerate case.

Examples

  • Results returned by using the default parameter settings:
    SELECT ST_AsText(ST_Envelope('LINESTRING(0 0,2 2)'::geometry ));
               st_astext
    --------------------------------
     POLYGON((0 0,0 2,2 2,2 0,0 0))
    (1 row)
                        
  • Results returned in a degenerate case:
    SELECT ST_AsText(ST_Envelope('LINESTRING(0 0,0 2)'::geometry ));
          st_astext
    ---------------------
     LINESTRING(0 0,0 2)
    (1 row)