I recently had the need to plot geographic data stored in MongoDB on a map. The data are points (latitude and longitude) for a project at WHERE, Inc. I was using Quantum GIS and the “Delimited Text” plugin that lets you load CSV files (back in the day of ArcView this was called adding an “Event Theme”). So the process was to export the data from MongoDB into a CSV file, editing that file so that latitude and longitude are separate columns, and then loading this edited file into Quantum GIS. This was fine once, maybe twice, but after that I was looking for a more automated solution. The result of this motivation is my MongoDB plugin for Quantum GIS.
The plugin can be found in the Quantum GIS plugin repository (direct link to the MongoDBLayer.zip containing the plugin).
Writing the plugin has been a bit of a challenge because I have not used Python before. A big thank you goes to Jason Sundram for helping me get up and running with Python. After getting past the python learning curve, I encountered some specific issues with PyQt. I.e., I was not able to install PyQt on OS X (I had to turn to Ubuntu) and that I found the buttons would fire a click event twice (I worked around it by using the “released” events instead). Overall, the plugin is simple. It lets you connect to MongoDB and load all the records in one collection as a layer to the map. There is no support to dynamically load content based on the map view and no writing to MongoDB. The plugin makes use of the PyMongo library, a Python driver for MongoDB.
how can i get pymongo installed/associated with the qgis’s python?
i have python 2.6 installed separately under program files, and pymongo is installed there; however, that’s not enough as i get a warning message that pymongo is needed for this particular qgis plugin.
thanks in advance
Hi, I’ll try to find out why this is not working. Can you verify your pymongo installation?
i’m sure pymongo is installed correctly because I’ve had no problem executing a few simple python/mongodb tutorials and have connected and created dbs via IDLE.
Thanks
-Sinjin
ever figure out why QGIS/MongoDB plugin may not see pymongo install?
thanks
OK, it happened to me as well. The issue was that the QGIS version I had installed was looking for python 2.6.x whereas I had pymongo installed for python 2.7.x. Updating QGIS to the latest version which uses python 2.7.x solved the issue.
You can check what version of python QGIS is using by opening the Python Console (in the plugins menu):
import sysprint sys.version
I hope this helps,
Markus
I took my pymongo install from my sitelib folder under python 2.7 and put it in the QGIS Python sitelibs folder(C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages).
Then I built BSON for 2.7 then moved it too.