The script uses the Google Maps API to reverse geocode latitude and longitude to zip code. The script takes a csv with at least the following 3 columns: 'uniqid', 'lat', and 'long' (See sample input file.) And produces a csv with zip codes appended to the existing columns.
Note that the Google Maps Reverse Geocoding API usage limit is 2,500 queries/IP/day.
- Python 2.7.5
- pygeocoder
latlong2zip.py [options] input_file
Options:
-h, --help show this help message and exit
-r, --refresh Refresh query and update Lat/Lon by Google Maps
Geocoding API
-o OUTFILE, --outfile=OUTFILE
CSV Output file name (default: output.csv)
python latlong2zip.py input.csv
The script will produce output.csv with appends a 'zipcode' column to input.csv.
Note The script will terminate with "ERROR: Google Geocoding API usage over limit" if Google Maps (Reverse) Geocoding APIs usage limit of 2,500 queries/IP/day is exceeded.