All Products
Search
Document Center

MaxCompute:ST_COVERS

Last Updated:Aug 26, 2026

ST_COVERS determines if the first geography object covers the second. This is true if all points of the second geography object are on the boundary or in the interior of the first geography object.

Syntax

BOOLEAN ST_COVERS(GEOGRAPHY <value1>, GEOGRAPHY <value2>)

Parameters

value1, value2: Required. Values of the GEOGRAPHY data type. You can construct GEOGRAPHY objects by using functions such as ST_GEOGPOINT, ST_GEOGFROMWKB, ST_GEOGFROMTEXT, ST_MAKELINE, and ST_MAKEPOLYGON.

Return value

Returns a BOOLEAN value.

  • Returns TRUE if all points of the second geography object lie on the boundary or in the interior of the first geography object; otherwise, returns FALSE.

  • Returns FALSE if either value1 or value2 is an empty geography object.

A geography object covers its own boundary nodes.

Examples

  • Example 1: Checks if the polygon POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) covers three points: (5, 5) outside the polygon, (0, 0) on its boundary, and (0.5, 0.5) in its interior.

    -- Returns TRUE because point(0 0) is on a boundary node of the polygon.
    SELECT ST_COVERS(ST_GEOGFROMTEXT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'), ST_GEOGPOINT(0, 0));
    
    -- Returns TRUE because point(0.5 0.5) is in the interior of the polygon.
    SELECT ST_COVERS(ST_GEOGFROMTEXT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'), ST_GEOGPOINT(0.5, 0.5));
    
    -- Returns FALSE because point(5 5) is outside the polygon.
    SELECT ST_COVERS(ST_GEOGFROMTEXT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'), ST_GEOGPOINT(5, 5));
  • Example 2: Shows that ST_COVERS returns FALSE when an argument is an empty geography object.

    -- Returns FALSE
    SELECT ST_COVERS(ST_GEOGFROMTEXT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'),ST_GEOGFROMTEXT('point empty'));

Related topics