cluelessresearch.com

political methodology, brazilian politics, etc.

Archive for November, 2007

Geocoding

geopy is a geocoding toolbox for python. See the website for installation instructions. It uses third-party geocoders (such as google maps) so you can add geographic coordinates to the addresses in your application. I cooked up my first python script to use it. You give it a csv file with addresses and it returns a csv file with addresses + latitude and longitude. It might be useful to someone out there.

from geopy import geocoders
g = geocoders.Google('your-google-maps-api-here')

import csv
writer = csv.writer(open("out.csv", "wb"))
writer.writerow(("endereco","cidade","estado","pais","latitude","longitude"))
reader = csv.reader(open("endereco.csv"))
for row in reader:
    now = row[0]+","+row[1]+","+row[2]+","+row[3]
    try: place, (lat, lng) = g.geocode(now)
    except: place, (lat, lng) = "NA", ("NA", "NA")
    writer.writerow((row[0],row[1],row[2],row[3],lat, lng))
No comments

QuickR

There is a new (I think) website for learning R that looks pretty decent: Quick-R(http://www.statmethods.net/). It was created by Robert Kabacoff, whom I had the pleasure to meet several months ago. We discussed R briefly at that time and he was just getting into it. Apparently he has been busy! The intended audience are users of SAS/SPSS/STATA transitioning to R. If that fits your bill, go ahead and take a look. If it doesn’t and you are already an experienced users, I am sure there are more than a couple of people you can point the website to.

No comments