Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.76 KB

st-within.md

File metadata and controls

55 lines (38 loc) · 1.76 KB
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

ST_WITHIN (NoSQL query)

[!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.

Syntax

ST_WITHIN(<spatial_expr_1>, <spatial_expr_2>)  

Arguments

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.

Return types

Returns a boolean value.

Examples

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":::

Remarks

  • 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.

Related content