Search code examples
geocodinggoogle-geocodergoogle-geocoding-api

Google - translating latitude, longitude into Geotarget locations


I have a bunch of locations (cities, counties, street level addresses) that I want to translate into the 100k locations found here: https://developers.google.com/adwords/api/docs/appendix/geotargeting

Let's say I've got:

location            | latitude      | longitude    | 
-----------------------------------------------------
New York, NY, USA   | 40.70         | -74.00       | 

And I want to map this to:

"21167","New York","New York, United States","US","State"

Is there a way of doing that? parsing text and matching it like that isn't an option.

The Google Geocode API only gives me a list of coordinates based on an address, not an ID from that file.

One thing I thought of would be to take each canonical_name from the file, open up Maps, get the coordinates for all locations and map my lat, long addresses to the nearest point.

Could it be done in a better/more accurate way?


Solution

  • Long story short, this can't be done for free.

    I made a selenium script that inputs the address in the Maps search, hits Enter (this centers the map to the coordinates I think), then pulls the coordinates from somewhere within the HTML or the URL it redirects to. I think.

    For stuff I couldn't find a match for, I got the latitude & longitude for the locations in the Geotargets CSV and picked the nearest one to my address.