- It allows you to efficiently execute spatial queries on a collection that contains geospatial shapes and points.
- It was created by two fields, specify the location field first, then the second field.
- In MongoDB, it has two types 2dsphere and 2d.
- Indexes work with spherical geometries that model the surface of the earth based on the WGS84 datum is 2dsphere.
- In this model, the surface of the earth is an oblate spheroid, meaning that there is some flattening at the poles.
- Indexes for points stored on a two-dimensional plane is 2d.
- In GeoJSON format 2dsphere allows you to specify geometries for points, lines, and polygons.
- A point is given by a two-element array, representing [longitude, latitude].
For example,
A line is given by an array of points:
For example,