ST_INTERSECTS (Azure Cosmos DB)

APPLIES TO: NoSQL

Returns a Boolean expression indicating whether the GeoJSON object (Point, Polygon, MultiPolygon, or LineString) specified in the first argument intersects the GeoJSON (Point, Polygon, MultiPolygon, or LineString) in the second argument.

Syntax

ST_INTERSECTS (<spatial_expr>, <spatial_expr>)  

Arguments

spatial_expr
Is a GeoJSON Point, Polygon, or LineString object expression.

Return types

Returns a Boolean value.

Examples

The following example shows how to find all areas that intersect with the given polygon.

SELECT a.id
FROM Areas a
WHERE ST_INTERSECTS(a.location, {  
    'type':'Polygon',
    'coordinates': [[[31.8, -5], [32, -5], [32, -4.7], [31.8, -4.7], [31.8, -5]]]  
})  

Here is the result set.

[{ "id": "IntersectingPolygon" }]  

Remarks

This system function will benefit from a geospatial index except in queries with aggregates.

Note

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.

Next steps