Tag Archives: Public Art

MongoDB in QGIS

28 Dec
Displaying my MongoDB Data

Displaying my MongoDB Data

I recently installed the MongoDB Plugin for QGIS. The plugin allows you to connect to a MongoDB and load your data. I stored point data – long and lat – for all the public art in Albuquerque. Using the plugin, I connected to my MongoDB and loaded them.

I had trouble getting the plugin to install. My fix was to install pymongo and BSON to my local Python2.7 then copy it from the site-libs to the QGIS directory (C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages). then I had to turn on the plugin under manage plugins.

This did the trick. Then I fired up my mongod, loaded QGIS and connected using the defaults. It prompted me for a Database and then a Collection. Looks like it requires a GEO2D. You can see my data in the image above.

Can’t wait to start playing….

Albuquerque Public Art

10 Dec

Albuquerque has released a bunch of data as part of their transparency initiative. The best of the data is in KML, which I am not thrilled about. Wish that open initiatives would use formats like CSV or JSON instead of SHP and KML.

Oh well, I have moved on. Their public art file is cool. It is a KML of points where you can find art in ABQ with a table of information and an image. I scrubbed the KML through some python scripts I wrote and got the Long, Lat, and a URL to an image. Let me add, they have a website with this map already, but it is an embedded ArcGIS Online map.   I am giving away the data in a python script that creates a MongoDB with geospatial indexing enabled(GEO2D).

The code is a lot of insert statements:

from pymongo import Connection
from pymongo import GEO2D

db=Connection().albuquerque
#db.drop_collection(“publicart”) you shouldn’t need this.
db.publicart.create_index([(“loc”,GEO2D)])

db.publicart.insert({“loc”:[35.1555,-106.591838],”name”:”Almond Blossom/Astronomy”,”popup”:”http://farm8.staticflickr.com/7153/6831137393_fa38634fd7_m.jpg”})
db.publicart.insert({“loc”:[35.0931,-106.664177],”name”:”Formas Esperando Palabra de Otros Mundos”,”popup”:”http://farm3.staticflickr.com/2167/2479129916_0d861b2600.jpg”})
db.publicart.insert({“loc”:[35.1143,-106.577991],”name”:”Sumer #24″,”popup”:”http://farm2.staticflickr.com/1416/908720823_e390a242f4.jpg”})
db.publicart.insert({“loc”:[35.0682,-106.570886],”name”:”Images”,”popup”:”http://farm8.staticflickr.com/7012/6831253349_52c0a680ba.jpg”})
……….

The full python file is on my website.

 

Albuquerque Public Art: A Mobile Leaflet.js Example

5 Dec
Mobile Leaflet Map with Geolocation, Clusters, and Icons.

Mobile Leaflet Map with Geolocation, Clusters, and Icons.

I was looking at the Albuquerque OpenData – it’s all in KML – and decided to make a mobile map using the public art file. The first thing I did was write a Python script to get the Long, Lat and URL of the image out as text. I renamed the KML to XML and imported it in to Excel. From there I deleted out several columns and stripped some information out by hand. Then I ran this script to get my JavaScript:

from xlrd import open_workbook
wb=open_workbook(‘PublicArt.xls’)
sheet=wb.sheet_by_index(0)
f=open(‘temp.txt’,’w+’)

for rownum in range(sheet.nrows):
a=”[“+str(sheet.cell_value(rownum,2))+” , “+str(sheet.cell_value(rownum,1))+” , “+'”<img src=’+”‘”+str(sheet.cell_value(rownum,3))+”‘”+’>”‘+”],\n”
f.write(a)

f.close()

I wrote my Leaflet map and put the output in as my markers. Then I made a new PNG using the Albuquerque Vase Logo. Lastly, I grabbed the LocateControl. View the live example.

If you view this page on an iPhone, it will ask for your current location. You can also click the location circle in the top left of the map – under the zoom controls.  Doesnt appear to work on Droid – but only tested on 1 device.

Just grab the code from the example by going to ‘page source’ in your browser – ctrl-u in Firefox.

If you do not have location enabled, you can go to this map.