MongoDB Documentation, Release 3.0.4 Points within a Circle Defined on a Sphere To select all grid coordinates in a “spherical cap” on a sphere, use $geoWithin with the $centerSphere operator. Specify an array that contains: • The grid coordinates of the circle’s center point • The circle’s radius measured in radians. To calculate radians, see Calculate Distance Using Spherical Geometry (page 537). Use the following syntax: The following example queries grid coordinates and returns all documents within a 10 mile radius of longitude 88 W and latitude 30 N . The example converts the distance, 10 miles, to radians by dividing by the approximate equatorial radius of the earth, 3963.2 miles: To build a geospatial 2d index, use the :method:.createIndex() <db.collection.createIndex()>‘ method and specify 2d . Use the following syntax: The 2d index uses the following optional index-specification options: By default, a 2d index assumes longitude and latitude and has boundaries of -180 inclusive and 180 non-inclusive . If documents contain coordinate data outside of the specified range, MongoDB returns an error. Important: The default boundaries allow applications to insert documents with invalid latitudes greater than 90 or less than -90. The behavior of geospatial queries with such invalid points is not defined. On 2d indexes you can change the location range. You can build a 2d geospatial index with a location range other than the default. Use the min and max options when creating the index. Use the following syntax: 533 8.3. Indexing Tutorials db.<collection>.find( { <location field> : { $geoWithin : { $centerSphere : [ [ <x>, <y> ] , <radius> ] } } } ) db.places.find( { loc : { $geoWithin : { $centerSphere : [ [ -88 , 30 ] , 10 / 3963.2 ] } } } ) db.<collection>.createIndex( { <location field> : "2d" , <additional field> : <value> } , { <index-specification options> } ) { min : <lower bound> , max : <upper bound> , bits : <bit precision> } Create a 2d Index Define Location Range for a 2d Index