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
11
votes
2 answers
Mongodb find query with $near and coordinates not working
I'm trying to make use of some geolocation functionality in mongodb. Using a find query with $near doesn't seem to work!
I currently have this object in my database:
{
"Username": "Deano",
"_id": {
"$oid": "533f0b722ad3a8d39b6213c3"
…

DeaIss
- 2,525
- 7
- 27
- 37
9
votes
2 answers
MongoDB $geoNear aggregation pipeline (using query option and using $match pipeline operation) giving different no of results
I am using a $geoNear as the first step in the aggregation framework. I need to filter out the results based on "tag" field and it works fine but I see there are 2 ways both giving different results.
Sample MongoDB Document
{
"position":…

Akshay Mehta
- 341
- 1
- 3
- 15
6
votes
1 answer
MongoDB:Can't canonicalize query: BadValue bad geo query
I indexed the field loc on 2dsphere and i am unable to run the geowithin query on Point type GeoJson data.
Here is the query:
db.test.find( { loc :
{ $geoWithin :
{ $geometry :
…

Swakesh
- 233
- 5
- 15
6
votes
4 answers
MongoDB 2dsphere index fails (malformed geometry?)
I'm currently trying to build an 2dsphere index, but the creation seems to fail.
The document on which the index creation fails is valid geojson (according to geojsonlint).
Also as far as I can see it obeys the MongoDB "Polygon" rules.
I would…

coalmee
- 1,334
- 2
- 16
- 27
5
votes
2 answers
MongoDB Error Code 16755 - Can't extract geo keys & duplicate vertices
When I try to create an index on geometry db.polygons.createIndex({"geometry":"2dsphere"}), it stops at a certain polygon with the error code 16755. It says it Can't extract geo keys and Duplicate vertices: 18 and 20.
So upon further inspection, it…

kaoscify
- 1,743
- 7
- 37
- 74
5
votes
1 answer
What is the internals of mongodb 2dsphere index?
Mongodb site shows the internals of 2d index is GeoHash.
I want to know the internals of 2dsphere index.
Is it GeoHash, Cartesian Tiers or other techs?
I just find the blog of mongodb site, new-geo-features, to introduce 2dsphere index.
But there is…

efei
- 281
- 1
- 3
- 14
5
votes
0 answers
Cant create 2dsphere index in mongoDB
When I try to create 2dsphere index in mongoDB i get this error msg:
> db.mahalle.createIndex({geometry:"2dsphere"})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"errmsg" : "exception: Can't extract geo…

Tom
- 173
- 2
- 13
4
votes
1 answer
MongoError: can't find any special indices: 2d (needs index), 2dsphere (needs index)
I am attempting to use MongoDB's Geospatial Indexing by querying for latitude and longitude points around a certain point using MongoDB's find method. I keep getting the error:
MongoError: can't find any special indices: 2d (needs index),…

Matt Goo
- 1,118
- 1
- 11
- 12
3
votes
1 answer
How to create index in mongodb with pymongo
I use scrapy crawl data and save it to mongodb, i want to save 2dsphere index in mongodb.
Here is my pipelines.py file with scrapy
from pymongo import MongoClient
from scrapy.conf import settings
class MongoDBPipeline(object):
global theaters
…

Morton
- 5,380
- 18
- 63
- 118
3
votes
1 answer
Mongodb geospatial indexes, 2d vs 2dsphere
According to the docs it says about 2d indexes:
The 2d index supports calculations on a flat, Euclidean plane. The 2d index also supports distance-only calculations on a sphere, but for geometric calculations (e.g. $geoWithin) on a sphere, store…

doc_id
- 1,363
- 13
- 41
3
votes
0 answers
Can't extract geo keys
I try create 2dsphere index in mongodb, but i get error
"Can't extract geo keys: { _id: ObjectId('57963b5365ba4df2c13a4965'),
loc: { coordinates: [ -180.0, 65.33018130000001 ], type: \"Point\" } }
longitude/latitude is out of bounds, lng: -180…

Kisin Pavel
- 153
- 1
- 1
- 9
3
votes
2 answers
Mongodb compound 2dsphere index dosen't work as expected
I have a collection called search2 with about 20000 documents like this:
{
"loc": {
"type": "Polygon",
"coordinates": [
[
[
43.78526674007639,
11.14739998758569
…

MarcoBiagi
- 163
- 7
3
votes
1 answer
MongoDb geoIntersects doesn't use IndexOnly
I have a collection called search2 with about 20000 documents like this:
{
"loc": {
"type": "Polygon",
"coordinates": [
[
[
43.78526674007639,
11.14739998758569
…

MarcoBiagi
- 163
- 7
2
votes
0 answers
mongodb Insert of geo object generated a high number of keys
I have a lot "Insert of geo object generated a high number of keys" entries in my log file and not sure if this actually affects any performance or other things.
I'm aware of the reason, I have a pretty big table with 2dsphere indexes combined with…

Simon Tretter
- 41
- 3
2
votes
0 answers
how to $geoWithin query using "MultiPoint" type?
I have the following document in the myCollection collection at MongoDB
{
"_id" : ObjectId("57e9176541a4e22ac83afcec"),
"location" : {
"type" : "MultiPoint",
"coordinates" : [
[
40.0,
…

Mr White
- 97
- 1
- 9