I'm currently playing with MongoDB and its geospatial queries. It’s pretty interesting so far, so I just thought I'd write something up to show how I'm using it with PyMongo!
Firstly, the obvious
pip install pymongo is needed. We will need a mongo client first, which is easy enough
It’s pretty neat - by default, MongoClient will connect to
You might want to do something like this instead though
We're going to want to create a MongoDB index on a document field to allow the geospatial magic to work. We will be creating a
Now all that is needed is to insert a document and run a query :) We'll insert a document that just has a
location field needs to be GeoJSON, which is a JSON standard for representing geographic features. It makes querying for documents super easy!