Created
February 11, 2014 18:54
-
-
Save marktyers/8941506 to your computer and use it in GitHub Desktop.
Simple #python script to extract traffic incidents from Bing Maps in #json format #321COM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import json | |
# http://msdn.microsoft.com/en-us/library/hh441726.aspx | |
# get lat/lon data from http://itouchmap.com/latlong.html | |
latN = str(52.477213) | |
latS = str(52.356601) | |
lonW = str(-1.615194) | |
lonE = str(-1.344656) | |
url = 'http://dev.virtualearth.net/REST/v1/Traffic/Incidents/'+latS+','+lonW+','+latN+','+lonE+'?key=AoonWsUSBrfwRFefuyHH70hI_mFh8mqBl-o1IuubEEwTPvT9wBKSdblV_E0HWZnw' | |
response = urllib2.urlopen(url).read() | |
data = json.loads(response.decode('utf8')) | |
resources = data['resourceSets'][0]['resources'] | |
print '----------------------------------------------------' | |
for resourceItem in resources: | |
description = resourceItem['description'] | |
print description; | |
print '----------------------------------------------------' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment