This tutorial will walk you through how to add reverse geocoding (latitude and longitude to addresses) in a Google Sheet.
Note: Geocodio only supports US and Canada. If you need global geocoding, you'll need to use another provider.
This process may take up to half an hour to set up, so you may want to grab a glass of water and a snack before diving in.
First you will need to install the API Connector Google Sheets add-on. It is free for basic use.
Create a Geocodio account and then create an API key here. To prevent runaway requests, consider not adding a credit card to your account to start (which will limit you to 2,500 lookups per day) or add a limit to your account.
Your coordinates must be formatted consistently and in the one-column format. Latitude and longitude must be in latitude-longitude order.
If you have the coordinates in columns A and B you can use this function:
=concatenate(A2,",",B2)
In the API Connector window, select Create from the top menu. If you've already set this up for forward geocoding, you'll need to create a new request type.
The Method should be set to Get.
Next, put this URL in the API URL Path box, replacing "YOUR_API_KEY" with your API key.
https://api.geocod.io/v1.7/reverse?api_key=YOUR_API_KEY&q=
Next, you'll need to configure the output. We suggest either "default" or "grid."
If you want to print the results to a new sheet, specify that in the Destination Sheet. If you want them in the same sheet, it doesn't matter what you put there.
Next, name and save the request. We suggest something simple and one-word like Geocodio or Reverse. (You'll need this soon.)
Press Save.
Next, run the request. It should fail with a 422 error. This is a good error! This means you have set it up correctly. (Don't worry.)
Now, let's go back to your spreadsheet.
The coordinates should be in one cell in latitude-longitude order.
In the next column over, you'll insert the ImportAPI function, which can only be used if you have the API Connector add-on installed.
This function should look like:
=ImportAPI("Geocodio",CONCATENATE("https://api.geocod.io/v1.7/reverse?q=",ENCODEURL(E2),"&api_key=YOUR_API_KEY&format=simple"))
Drag the formula down the spreadsheet, and it should run.
The addresses will then be printed alongside your coordinates.
This also works with field appends, so you can, for example, add Census FIPS codes or timezones to your spreadsheet, like so:
=ImportAPI("Geocodio",CONCATENATE("https://api.geocod.io/v1.7/reverse?q=",ENCODEURL(E2),"&api_key=YOUR_API_KEY&format=simple&fields=census"))
=ImportAPI("Geocodio",CONCATENATE("https://api.geocod.io/v1.7/reverse?q=",ENCODEURL(E2),"&api_key=YOUR_API_KEY&format=simple&fields=timezone"))
=ImportAPI("Geocodio",CONCATENATE("https://api.geocod.io/v1.7/reverse?q=",ENCODEURL(E2),"&api_key=YOUR_API_KEY&format=simple&fields=school"))
=ImportAPI("Geocodio",CONCATENATE("https://api.geocod.io/v1.7/reverse?q=",ENCODEURL(E2),"&api_key=YOUR_API_KEY&format=simple&fields=census"))
=ImportAPI("Geocodio",CONCATENATE("https://api.geocod.io/v1.7/reverse?q=",ENCODEURL(E2),"&api_key=YOUR_API_KEY&format=simple&fields=statcan"))
And so forth.
Note: If you need to append Congressional districts, you will need to leave space for three rows per address to accommodate Representative and Senator information. We suggest uploading your spreadsheet if using Congressional districts.
=ImportAPI("Geocodio",CONCATENATE("https://api.geocod.io/v1.7/reverse?q=",ENCODEURL(E2),"&api_key=YOUR_API_KEY&format=simple&fields=cd"))
You can also automate geocoding in Google Sheets. See API Connector's documentation.