Index that supports queries that calculate geometries on an earth-like sphere. It supports data stored as both GeoJSON objects and as legacy coordinate pairs.
Questions tagged [2dsphere]
69 questions
2
votes
1 answer
Mongoose Mongo 2dsphere geoWithin
After reading many questions that are SO close to mine, and reading the MongoDB docs and Mongoose docs, I still cannot answer my question.
Using express 4.13.4, mongoose 4.4.10, mongodb 2.1.14 on Node 4.4.0
My Mongoose Location schema:
var schema…

westandy
- 1,360
- 2
- 16
- 41
2
votes
1 answer
Mongoose - how to add 2dsphere index on custom type?
I'm using Mongoose with Mongoose-geojson-schema however I cannot add 2dsphere index on my field:
new Schema({
district: {
type: String,
trim: true,
unique: true,
required: true
},
area: {
type: GeoJSON.FeatureCollection,
…

Kosmetika
- 20,774
- 37
- 108
- 172
2
votes
1 answer
mongodb geoWithin queries very slow
I'm running a geoWithin query with a polygon which is around 500km², and it's taking a very long time to execute, anywhere between 30s and 5 minutes. The collection is only 180k rows, and the polygon could be anywhere from 2km² to 10,000km². The…

royse41
- 2,310
- 4
- 22
- 29
2
votes
1 answer
MongoDb cannot create 2dsphere index on collection with Polygon and MultiPolygon
I'm trying to add a 2dsphere index and run into problems with malformed geometry (using MongoDB 2.6 with 2dsphere index version 2)
The collection contains both documents with Polygon geometry as documents with MultiPolygon geometry. Mongo throws a…

Ropstah
- 17,538
- 24
- 120
- 194
2
votes
1 answer
mongoldb insert does the property order matters?
I have a collection with the following indices.
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "bs.locations"
},
{
"v" : 1,
"key" : {
"location"…

halber
- 197
- 2
- 11
2
votes
1 answer
Query returns wrong result
I've stuck with a problem of matching items inside a polygon (simple box). I can't figure out why the item which is inside the queried box is not resulting. So here what i have:
>db.testing.getIndexes();
{
"0" : {
"v" : 1,
"key"…

ofetisov
- 44
- 5
2
votes
2 answers
Mongodb Sphere index rejects my object
Hi i have an COllection with an 2d sphere index
wayCollection.createIndex(new BasicDBObject("poly", "2dsphere"));
i when i try to insert a certain object i get an error:
Exception in thread "main" com.mongodb.WriteConcernException: { "serverUsed" :…

wutzebaer
- 14,365
- 19
- 99
- 170
1
vote
1 answer
MongoDB and geospatial queries: unknown geo specifier: $geometry: null
i'm experimenting with mongodb and geospatial queries. I made the following collection:
shape> db.shape.find()
[
{
_id: ObjectId("61ab50d2056b5357b5e23e56"),
name: 'Point1',
structure: { type: 'Point', coordinates: [ 2.5, 2.5 ] }
},
…

rekotc
- 595
- 1
- 10
- 21
1
vote
1 answer
MongoDB Time-Spatial Query is slower with 2dsphere Index
Recently, I started to investigate the performance of MongoDB with AIS Data.
I used a collection with 19m documents with proper field types as described in the definition.
I also created a new geoloc field with type: (Point) from coordinates…

Stavros Koureas
- 1,126
- 12
- 34
1
vote
1 answer
MongoDB find $near in object array
I started to work with MongoDB API, beacause we are using Azure Cosmos DB.
Tried examples using $near in MongoDB with the basic structure {key:"A": localtion:{type:"Point", coordinates:[1,2]}}, and works well. The ploblem is when i need to use an…

Paul Escarcena
- 13
- 2
1
vote
0 answers
How to create a 2DSphere index on a array of locations?
I Have this collection :
{
geopositions: [
{type:"Point", coordinates: [-10, 12]},
{type:"Point", coordinates: [-25, 85]}
]
}
but when i try to create the 2DSphere index on geopositions with db.myCollection.createIndex(…

zeus
- 12,173
- 9
- 63
- 184
1
vote
1 answer
How to create geo index in mongoose
I try to create a 2dsphere index in my collection, when i create a user that i should has a 2dsphere index.
I take a reference from this answer Create & Find GeoLocation in mongoose
I use the code is this in my case:
DriverSchema.index({ "geometry":…

Morton
- 5,380
- 18
- 63
- 118
1
vote
1 answer
Create geospatial and type index together in MongoDB?
I want to use two indexes from different index types (2dsphere and text) by using this command :
db.mycoll.createIndex({"@geolocationable":"2dsphere",name:"text"})
but I get the following Error:
"errmsg" : "bad index key pattern {…

Mr White
- 97
- 1
- 9
1
vote
1 answer
Error creating a geospatial index on the data after importing data from an excel doc
I have imported this data from an excel document.
{
"_id" : ObjectId("57440d63a458f726a8f95bfe"),
"state" : "WEST BENGAL",
"bank" : "STATE BANK OF INDIA",
"ifsc" : "SBIN0000001",
"micr code" : "700002021",
"branch" :…

Coded9
- 159
- 2
- 14
1
vote
1 answer
Create GeoJson from coordinates array in the same Mongodb collection
I want to modify my mongodb collection from 2d to 2dsphere.
I have this structure in my db.users:
{
"_id" : "1c6930387123e960eecd65e8ade28488",
"interests" : [
{
"_id" : ObjectId("56a8b2a72f2c2a4c0250e896"),
"coordinates" :…

Raquel Úbeda
- 13
- 2