> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for ST_COVERS function

# ST_COVERS

The `ST_COVERS` function determines if one `GEOGRAPHY` object fully encompasses another. Specifically, it checks whether every point in the second `GEOGRAPHY` object (`geo2`) lies within or on the boundary of the first `GEOGRAPHY` object (`geo1`). If `geo1` covers `geo2`, the function returns `TRUE`; otherwise, it returns `FALSE`. This function is commonly used to assess spatial relationships, such as whether a larger geographic area completely includes a smaller one.

If either `geo1` or `geo2` is empty, `ST_COVERS` will return `FALSE`.

Before performing the coverage check, `geo1` and `geo2` are aligned through a snapping process, ensuring precise calculation. For more details on snapping, refer to the [snapping documentation](/reference-sql/data-types/geography#snapping).

## Comparison with [ST\_CONTAINS](/reference-sql/functions-reference/geospatial/st_contains)

`ST_COVERS` is similar to `ST_CONTAINS`, but there is a key distinction: `ST_CONTAINS` returns `FALSE` if all points in `geo2` lie exactly on the boundary of `geo1`, while `ST_COVERS` will return `TRUE` in this case. If this distinction is not important, use `ST_COVERS`, which is more efficient to compute in Firebolt.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
ST_COVERS(<geo1>, <geo2>)
```

## Parameters

| Parameter | Description                                                           | Supported input types |
| :-------- | :-------------------------------------------------------------------- | :-------------------- |
| `<geo1>`  | The object being checked to see if it fully covers the second object. | `GEOGRAPHY`           |
| `<geo2>`  | The object being checked to see if it fully covers the first object.  | `GEOGRAPHY`           |

## Return Type

`ST_COVERS` returns a value of type `BOOLEAN`.

## Examples

The following codes example creates a Polygon and a Point around Times Square in New York City from their WKT representations and checks if the Polygon covers the Point:

<div className="query-window">
  ```
  SELECT ST_COVERS(
  ST_GEOGFROMTEXT('POLYGON((-73.98519512134791 40.75939223091697, -73.98566488210841 40.75807135585606, -73.9856079414103 40.75804080469413, -73.98470163529633 40.75918017383259, -73.98519512134791 40.75939223091697))'),
  ST_GEOGFROMTEXT('POINT(-73.98504378555772 40.75894662495352)')
  ) AS result;
  ```

  | result <span>boolean</span> |
  | :-------------------------- |
  | True                        |

  <p><span>Rows: 1</span><span>Execution time: 6.01ms</span></p>
</div>

The following example illustrates the difference between `ST_CONTAINS` and `ST_COVERS`. The Polygon `POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))` covers, but does not contain the LineString `LINESTRING(0 0, 0 0.5)` because it only lies on the Polygon's boundary and does not intersect the interior of the Polygon. The LineString `LINESTRING(0 0, 0 0.5, 0.5 0.5)` only partially lies on the Polygon's boundary but also intersects its interior, so it is covered and contained.

<div className="query-window">
  ```
  SELECT
      polygon,
      linestring,
      ST_CONTAINS(
          ST_GEOGFROMTEXT(polygon),
          ST_GEOGFROMTEXT(linestring)
      ) AS contains,
      ST_COVERS(
          ST_GEOGFROMTEXT(polygon),
          ST_GEOGFROMTEXT(linestring)
      ) AS covers
      FROM UNNEST (
          ['POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))','POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'],
          ['LINESTRING(0 0, 0 0.5)','LINESTRING(0 0, 0 0.5, 0.5 0.5)']
      ) AS shapes(polygon, linestring);
  ```

  | polygon <span>text</span>          | linestring <span>text</span>    | contains <span>boolean</span> | covers <span>boolean</span> |
  | :--------------------------------- | :------------------------------ | :---------------------------- | :-------------------------- |
  | POLYGON((0 0, 0 1, 1 1, 1 0, 0 0)) | LINESTRING(0 0, 0 0.5)          | False                         | True                        |
  | POLYGON((0 0, 0 1, 1 1, 1 0, 0 0)) | LINESTRING(0 0, 0 0.5, 0.5 0.5) | True                          | True                        |

  <p><span>Rows: 2</span><span>Execution time: 6.03ms</span></p>
</div>
