> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# $centerSphere (query predicate operator)

## Definition

Defines a circle for a [geospatial](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-geospatial) query that uses spherical geometry. The query returns documents that are within the bounds of the circle. You can use the [`$centerSphere`](https://www.mongodb.com/docs/manual/reference/operator/query/centersphere.md#mongodb-query-op.-centerSphere) operator on both [GeoJSON](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-GeoJSON) objects and legacy coordinate pairs.

To use [`$centerSphere`](https://www.mongodb.com/docs/manual/reference/operator/query/centersphere.md#mongodb-query-op.-centerSphere), specify an array that contains:

- The grid coordinates of the circle's center point, and

- The circle's radius measured in radians. To calculate radians, see [Convert Distance to Radians for Spherical Operators.](https://www.mongodb.com/docs/manual/core/indexes/index-types/geospatial/2d/calculate-distances.md#std-label-calculate-distance-spherical-geometry)

```javascript
{
   <location field>: {
      $geoWithin: { $centerSphere: [ [ <x>, <y> ], <radius> ] }
   }
}
```

**Important: If you use longitude and latitude, specify longitude first.**

## Behavior

Applications can use [`$centerSphere`](https://www.mongodb.com/docs/manual/reference/operator/query/centersphere.md#mongodb-query-op.-centerSphere) *without* having a geospatial index. However, geospatial indexes support much faster queries than the unindexed equivalents.

Both [2dsphere](https://www.mongodb.com/docs/manual/core/indexes/index-types/geospatial/2dsphere.md#std-label-2dsphere-index) and [2d](https://www.mongodb.com/docs/manual/core/indexes/index-types/geospatial/2d.md#std-label-2d-index) geospatial indexes support [`$centerSphere`.](https://www.mongodb.com/docs/manual/reference/operator/query/centersphere.md#mongodb-query-op.-centerSphere)

## Example

The following example queries grid coordinates and returns all documents within a 10 mile radius of longitude `88 W` and latitude `30 N`. The query converts the distance to radians by dividing by the approximate equatorial radius of the earth, 3963.2 miles:

```javascript
db.places.find( {
  loc: { $geoWithin: { $centerSphere: [ [ -88, 30 ], 10/3963.2 ] } }
} )
```
