All Products
Search
Document Center

MaxCompute:ST_BOUNDINGBOX

Last Updated:Aug 26, 2026

The ST_BOUNDINGBOX function returns the bounding box of a geography object.

Syntax

STRUCT ST_BOUNDINGBOX(GEOGRAPHY <value>)

Parameters

value: Required. A value of the GEOGRAPHY data type. You can use functions such as ST_GEOGPOINT, ST_GEOGFROMWKB, ST_GEOGFROMTEXT, ST_MAKELINE, and ST_MAKEPOLYGON to create GEOGRAPHY objects.

Return value

Returns a STRUCT<xmin DOUBLE, ymin DOUBLE, xmax DOUBLE, ymax DOUBLE> value, which describes the coordinate range of the bounding box. The fields are:

  • xmin: The minimum longitude.

  • xmax: The maximum longitude.

  • ymin: The minimum latitude.

  • ymax: The maximum latitude.

The function follows these rules:

  • If the input is null or an empty geography object, the function returns NULL.

  • MaxCompute performs geospatial calculations on a sphere, not with planar geometry. Additionally, the underlying S2 library may introduce minor precision errors. As a result, the returned coordinates might differ slightly from the input coordinates.

Examples

  • Example 1: Use the ST_GEOGFROMTEXT function to create a polygon and return its bounding box.

    SELECT ST_BOUNDINGBOX(ST_GEOGFROMTEXT('POLYGON ((0 0, 0.1 0, 0.1 0.1, 0 0.1, 0 0))'));
    
    -- Returns:
    +------------------------------------------------------------------------------+
    | _c0                                                                          |
    +------------------------------------------------------------------------------+
    | {xmin:0.0, ymin:-3.8199962864073534e-14, xmax:0.1, ymax:0.10000003807717585} |
    +------------------------------------------------------------------------------+
  • Example 2: Handle null values and empty geography objects.

    -- The input is an empty geography object. The function returns NULL.
    SELECT ST_BOUNDINGBOX(ST_GEOGFROMTEXT('point empty'));
    
    -- The input is null. The function returns NULL.
    SELECT ST_BOUNDINGBOX(ST_GEOGFROMTEXT(null));

Related topics