With Google Map API, you can do a lot of thing. Here I will use it to turn latitude and longitude into human-readable addresses.
This script has 2 parts. The first part generate a random location, ie latitude and longitude, with the Gaussion distribution which is a method in random package. Then it turns a coordinate into an address with The Google Geocoding API.
Note that use of the Google Geocoding API is subject to a query limit of 2,500 geolocation requests per day. Read more restrictions about Google Map API here:http://code.google.com/apis/maps/terms.html
#encoding:utf-8#Created by Liang Sun <i@liangsun.org> in 2012importurllib2importre,json,time,hashlib,randomimportMultipartPostHandlerfromgeventimportpoolfromgeventimportmonkeyfromurllib2importURLError,HTTPErrormonkey.patch_all()defget_address():u=100000.0v=1000000.0longitude=int(random.gauss(116467615,u))latitude=int(random.gauss(39923488,u))print"longitude=%d,latitude=%d"%(longitude,latitude)url='http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false&language=zh-CN'%(latitude/v,longitude/v)opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(),urllib2.HTTPRedirectHandler())try:str_content=opener.open(url).read()exceptHTTPError,e:print'Error code: ',e.codetime.sleep(36)returnget_address()exceptURLError,e:printe.reasontime.sleep(36)returnget_address()ifstr_content:content=json.loads(str_content)ifcontent['status']=='OK':address=content['results'][0]['formatted_address']ifaddress.find(' ')>0:address=address[:address.find(' ')]address=address.encode('utf-8')return(longitude,latitude,address)else:printcontent['status'].encode('utf-8')+"!!!!!!!!!!!!!!!!!!!!!!!!!!!!"time.sleep(36)# This is due to the 2500/24h limit.returnget_address()