Prerequisites: MongoDB and Python
- a field named type that specifies the GeoJSON object type and
- a field named coordinates that specifies the object’s coordinates.
Note: If specifying latitude and longitude coordinates, list the longitude first and then latitude.
- Pymomgo: This module is used to interact with the MongoDB. To install it type the below command in the terminal.
pip install pymongo OR condo install pymongo
- Matplotlib: This library is used for plotting graphs
- Basemap: This module is used for plotting maps using Python. To install this module type the below command in the terminal.
conda install basemap
Steps to use MongoDB Atlas:
- Open the MongoDB Atlas Cloud from here.
- Create the account by choosing the package suitable for you (You may also choose the free version which will be enough for this article and for learning purpose).
- Click on the Cluster view positioned at the left menu bar.
- Click on the Ellipses button
(...)and select Load Sample Dataset.
- After the sample dataset is added then click on the connect button.
- Then whitelist the IP address (choose your current IP address or type the 0.0.0.0/0 IP for allowing it to access from everywhere. Click the button shown in the below image.
- Then click connect to applications button.
- Copy the cluster_uri and paste it to a “course_cluster_uri”.
Below is the implementation.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Plotting Geospatial Data using GeoPandas
- MongoDB and Python
- MongoDB Python | Insert and Update Data
- MongoDB python | insert(), replace_one(), replace_many()
- MongoDB python | Delete Data and Drop Collection
- Python MongoDB - Find
- Python MongoDB - Sort
- Create a database in MongoDB using Python
- 3D Plotting sample Data from MongoDB Atlas Using Python
- Python Mongodb - Delete_one()
- Python Mongodb - Delete_many()
- Python MongoDB - Update_one()
- How to fetch data from MongoDB using Python?
- How to access a collection in MongoDB using Python?
- Python MongoDB - insert_many Query
- Drop Collection if already exists in MongoDB using Python
- Python MongoDB - Update_many Query
- Python MongoDB - insert_one Query
- Python MongoDB - find_one Query
- How to create index for MongoDB Collection using Python?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.