- Reference >
- Operators >
- Query and Projection Operators >
- Geospatial Query Operators >
- $geoIntersects
$geoIntersects¶
On this page
Definition¶
-
$geoIntersects
¶ New in version 2.4.
Selects documents whose geospatial data intersects with a specified GeoJSON object; i.e. where the intersection of the data and the specified object is non-empty. This includes cases where the data and the specified object share an edge.
$geoIntersects
uses spherical geometry.$geoIntersects
does not require a geospatial index. However, a geospatial index will improve query performance. Only the 2dsphere geospatial index supports$geoIntersects
.The
$geoIntersects
operator uses the$geometry
operator to specify the GeoJSON object and has the following form:Important
If you use longitude and latitude, specify coordinates in order of: longitude, latitude.
Behavior¶
For $geoIntersects
queries, GeoJSON geometries must
have an area less than the area of a single hemisphere. For geometries
larger than a single hemisphere, MongoDB queries for the smaller of the
complementary geometries. For geometries equal to a single hemisphere,
MongoDB makes no guarantees as to which geometry (the specified
geometry or the complementary) it uses.
Example¶
The following example uses $geoIntersects
to select all
loc
data that intersect with the Polygon defined by
the coordinates
array.