• Stars
    star
    332
  • Rank 126,957 (Top 3 %)
  • Language
    JavaScript
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Geocode from addresses to latitude / longitude, and vice versa using Google Sheets

Google Sheets Geocoding Macro

How It Works

Geocode from addresses to latitude / longitude, and vice versa using Google Sheets.

Test Sheet

Try the script out on a Test Sheet with sample address data. You can enter your own address data and geocode it in the rows below.

You must be logged into a Google Account before the Geocode menu will appear.

Any data you enter will be automatically deleted every Sunday at 4AM CEST, this isn't for long term storage.

Nope.

Test Sheet is removed due to:

  • Google not locking down Apps Script editing capabilities for Viewers on the Sheet. Because you can lock cells, but you can't lock code! Minor oversight!
  • too many people then editing the Apps Script code
  • too many people then breaking the Apps Script code and not fixing it afterwards
  • people immediately breaking the Cleanup code so that their data stays forever (let's boil the oceans together!)
  • people adding random Extensions to this shared Sheet
  • Google not providing a way at all to remove Extensions that Viewers have added
  • people associating the Sheet with their own Google Cloud Platform projects and breaking it for me and everyone else
  • Google not providing any sensible or quick ways to disassociate other peoples' GCP Project IDs (no I do not want to screw around in the Google Cloud Console all afternoon)
  • me getting notifications from Google every time people now want access to the sheet I created publicly, when access was not an issue before (to be fair, this probably changed as Google changed things in their backend to compel authentication to a once-public API)
  • ... other idiotic shenanigans

Good luck, this was a great experiment in the tragedy of the commons.

A few days ago, someone dropped a yogurt in the entrance hall to my apartment building and didn't clean it up. It was still there > 24 hours later, curdling into sour cream. Cool.

Multicolumn Addresses β†’ Latitude, Longitude

Now it supports geocoding using address data spread across multiple columns.

The way this works is: You select a set of columns containing the data, and the geocoding process puts the latitude, longitude data in the rightmost two columns. It will overwrite any data in those two columns.

Some care is needed, as it will concatenate all columns except the rightmost two columns to create the address string.

Multicolumn Address Geocoding

Latitude, Longitude β†’ Nearest Address

It also supports reverse geocoding.

Simply select the latitude, longitude columns and it will place the nearest address data in the rightmost column. It will overwrite any data in that column.

Less care is needed, as it will automatically use the leftmost two columns as the latitude, longitude pair.

Reverse Geocoding

Latitude, Longitude β†’ Address Components

It now supports reverse geocoding and splitting the address components into different columns.

See the Reverse To Components tab in the Test Sheet.

Reverse Geocoding to Address Components

Map Cells

It now supports mapping the Latitude, Longitude pairs in the Mapping tab.

Mapping Coordinates

Adding It To Your Own Sheet

Step 1. Create or Open a Google Sheet and add addresses to it.

open google sheet

Step 2. Tools -> Script Editor

edit the script

Step 3. Copy this script code into the Code.gs editor, replacing everything.

use geocoding script code

Step 4. Save

save code

Step 5. Reload Sheet

reload sheet

Step 6. Run Geocode, Click Through Warnings

run geocode, click through warnings

That's it.

Troubleshooting

  • I don't see the Geocode menu!

    You must be logged into a Google Account before the Geocode menu will appear. Anonymous / not logged-in users will not work, Incognito Mode will not work.

  • It gives me a bunch of warnings when I run it the first time.

    If you're using the Test Sheet, this means that the script will have access to the data you are entering. Don't enter anything you wouldn't want me to see, because as the owner of the shared Sheet, I see the data that gets put into it.

    If you've added the script to your own sheet, this means that the script will have access to the data you are entering. Since you're the owner of your Sheet, this isn't an issue. You can always audit the script by reading the source code in this repository.

  • It returns latitude / longitude data using "," instead of "." separators.

    There's not much I can do about the return formats, but a user reported that adding the following array formula to the latitude / longitude columns changes the separators for them: =ARRAYFORMULA(SUBSTITUTE(C2:C;",";".")).

    Make sure you specify the correct columns.

More Repositories

1

TwitGrid

Because TweetDeck is a mess at times.
HTML
76
star
2

provision-osx

Batch files to provision OS X as a virtual machine host and manage those VMs.
Shell
71
star
3

ArduinoShell

A command shell to interact with built-in Arduino features via the Arduino IDE Serial Monitor or terminal programs like minicom and CoolTerm
C++
30
star
4

localization-spreadsheet-jsonify

A Google App Script that lets you easily access a localization/translation Google spreadsheet in JSON format.
Python
14
star
5

dockarchive

Dockerfiles organized into a hierarchy that build related images for Docker.
Shell
10
star
6

mbed-memory-status

Print thread and ISR stack locations and sizes, and heap location and size at runtime.
C
9
star
7

WindowsHardening

A collection of tips to harden your Windows computer and Chrome browser.
Batchfile
7
star
8

userDefineLang_Mustache

A user-defined language file to syntax highlight Mustache templates in Notepad++.
5
star
9

provision-digitalocean-vpn

Ansible scripts to provision a private VPN server on DigitalOcean.
5
star
10

provision-windows

A batch file to provision Windows XP as a virtual machine guest.
Shell
4
star
11

Shrinkr

Smart batch transcoding for videos and proxy file generation, with rework avoidance
Python
4
star
12

SpiceShredder

IKEA spice grinder + 3D printer + electric drill = spice shredder
Batchfile
4
star
13

pystache-django-native

Seamlessly use Mustache, Pystache, Handlebars templates using Django's render() functions.
Python
4
star
14

esptool-test

Simple script to test esptool.py with different baud rate settings.
Shell
2
star
15

mbed-power-profiling

Power usage tests with mbed OS and Nordic nRF5
C++
2
star
16

ffmake

ffmake: Yet Another Build System (but hopefully one that doesn't suck)
Python
1
star
17

FabrikUml

A quick little PlantUML previewer, using JavaFX.
Java
1
star
18

smartphone-tablet-ultrabook-holder

3D-printable device holder.
1
star