title | titleSuffix | description | author | ms.author | ms.reviewer | ms.service | ms.subservice | ms.topic | ms.devlang | ms.date | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|
ST_WITHIN |
Azure Cosmos DB for NoSQL |
An Azure Cosmos DB for NoSQL system function that returns if one GeoJSON object is within another. |
jcodella |
jacodel |
sidandrews |
cosmos-db |
nosql |
reference |
nosql |
02/27/2024 |
query-reference |
[!INCLUDENoSQL]
Returns a boolean expression indicating whether the GeoJSON object (GeoJSON Point, Polygon, or LineString expression) specified in the first argument is within the GeoJSON object in the second argument.
ST_WITHIN(<spatial_expr_1>, <spatial_expr_2>)
Description | |
---|---|
spatial_expr_1 |
Any valid GeoJSON Point, Polygon, MultiPolygon or LineString expression. |
spatial_expr_2 |
Any valid GeoJSON Point, Polygon, MultiPolygon or LineString expression. |
Returns a boolean value.
The following example shows how to find if a Point is within a Polygon.
:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/st-within/query.sql" highlight="2-32":::
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/st-within/result.json":::
- This function benefits from a geospatial index except in queries with aggregates.
- The GeoJSON specification requires that points within a Polygon be specified in counter-clockwise order. A Polygon specified in clockwise order represents the inverse of the region within it.