In [ ]:
'''
This module uses the sodapy API
to querry the nyc wifi hotspots data
provided at 
https://nycopendata.socrata.com/City-Government/NYC-Wi-Fi-Hotspot-Locations/yjub-udmw?
for wifi service provided by downtown brooklyn partnership
and plots the information on google maps
creating an html file in your current location.
Author: Mohit Sharma
Organization: NYU CUSP
Date: Aug 25, 2015
'''
__author__ = 'Mohit Sharma'
__version__ = 'Demo'
from sodapy import Socrata
from pymaps import maps

In [ ]:
# I have stored my password (that I use to login at Socrata)
# in a text file.
with open('pwd.txt', 'r') as f:
    pwd = f.readline()

In [ ]:
# Create a Socrata (client) Object
client = Socrata(domain="data.cityofnewyork.us", app_token="3iLvxGFqvCCxBqucwCck4yEcN", username="mohitsharma44@gmail.com", password=pwd.strip('\n'))

In [ ]:
# Now use client's get method to querry the data from the 
# requested resource
tp = client.get("/resource/yjub-udmw.json", where="provider='Downtown Brooklyn'", limit=10 )

In [ ]:
# Initialize a map  with latitude and longitude of center point  
# and map zoom level
mymap = maps(40.6931177,-73.9867438, 14)

In [ ]:
# add points on map for all the wifi hotspots 
# using the object created above.
for i in range(len(tp)):
    mymap.addpoint(float(tp[i]['location_lat_long']['latitude']), float(tp[i]['location_lat_long']['longitude']), "#0000FF", title=tp[i]['location'])

In [ ]:
# Create a map inside current working directory.
mymap.draw('./mymap.html')