Skip to content

Instantly share code, notes, and snippets.

@marktyers
Created February 11, 2014 18:54
Show Gist options
  • Save marktyers/8941506 to your computer and use it in GitHub Desktop.
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
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