-
Notifications
You must be signed in to change notification settings - Fork 6
Spatial Query Examples
Show all collections
show collections
Show all of the data in the images collection
db.images.find()
Show only the location data
db.images.find({}, {"loc": 1})
Show only the meta data
db.images.find({}, {"meta": 1})
Show only the ref1 data
db.images.find({}, {"ref1": 1})
Show all points near those coordinates
db.images.find({"loc" : {$near:{$geometry:{"type": "Point", "coordinates" : [ 153.90251141089607, -39.585368948047375 ] }}}})
Show all points that fall within that box of loc coordinates [bottom left lon, bottom left lat], [upper right lon, upper right lat]
db.images.find({"loc" : {$geoWithin:{$box:[ [ 0, 0 ], [100, 100] ] }}})
Show all points that fall within that box of loc coordinates but only show the location data
db.images.find({"loc" : {$geoWithin:{$box:[ [ 0, 0 ], [100, 100] ] }}}, {"loc":1})
Show the loc data of the first point that falls within the box
db.images.findOne({"loc" : {$geoWithin:{$box:[ [ 0, 0 ], [100, 100] ] }}})["loc"]