Converting the address to latitude and longitude is known as geocoding. Whereas, converting the latitude and longitude to an address is called reverse geocoding.
Because I am probably not the only person who would like to reverse geocode a dataset, I thought it would be helpful to share my own reverse geocoding process.
Ideally, the dataset would first be in a csv file– with latitude was in one column and longitude in another.
I came across a script that could be used with Google Sheets. It’s on Stack Overflow and called “Get City, State, Country from Latitude and Longitude in Google Sheets. Per the instructions provided by Stack Overflow user Gabriel Rotman, I created a Google Sheet template.
Here is a link to an open, public Google Sheet Template that I created. Feel free to make a copy of it, and then edit it to fit your own needs!
This Google Sheet will provide the address when given the latitude and longitude. The following is the formula: “=reverse_geocode(A1,B1).”
Otherwise, you can copy and paste the script yourself into the ‘<> Script editor’ portion of your Google Sheet (under ‘Tools’). Script is below:
function reverse_geocode(lat,lng) {
Utilities.sleep(1500);
var response = Maps.newGeocoder().reverseGeocode(lat,lng);
for (var i = 0; i < response.results.length; i++) {
var result = response.results[i];
Logger.log('%s: %s, %s', result.formatted_address, result.geometry.location.lat,
result.geometry.location.lng);
return result.formatted_address;
}
}
Again, all credit for the script goes to Stack Overflow user Gabriel Rotman — much thanks to Gabriel!
Cheers!
Thank you for this!
I love matcha too!
Glad it was helpful!
Thank you so much i have been searching for an answer for past 2 days
Happy to help!
why is it loading forever!!!
Hi Sony, Maybe try less addresses at first? Or re-fresh the page? I think I recall running into that. Did I already share the sheet with you? – De
thank you soooo much
You’re welcome Pauline!
Thanks much for this effort. Does anyone know what the limit of lookups per day is? I fed it probably too large of a chunk and it’s telling me the service has been invoked too many times in one day. I need to reverse geocode city names for about 1500 lat/lons. Thanks!
loving it …! thank you!
Thank you so much…..
this helped me alot
Thanks again
I am glad it helped! You’re welcome!
Do you know if there is a way to return the name of the place instead of the address?
I have businesses who provide their name and lat & long and I want to double check the lat and long match the name…
Thanks 😉
Thank You, wish you always healty and happy…
Thank you ..
Thank you for this, you are just a saviour!
thank you so much for sharing…