Skip to content

Instantly share code, notes, and snippets.

@samuelleach
Forked from mjrich/google-refine-geocoding
Created July 5, 2013 08:59
Show Gist options
  • Save samuelleach/5933087 to your computer and use it in GitHub Desktop.
Save samuelleach/5933087 to your computer and use it in GitHub Desktop.
Step One
Fetch URL based on column:
'http://www.datasciencetoolkit.org/maps/api/geocode/json?sensor=false&address=' + escape(value, 'url')'
Step Two
Parse Json for longitude:
value.parseJson()["results"][0]["geometry"]["location"]["lng"]
then latitude:
value.parseJson()["results"][0]["geometry"]["location"]["lat"]
Source: http://www.youtube.com/watch?v=5tsyz3ibYzk&feature=player_embedded
@samuelleach
Copy link
Author

Example longitude and latitude:
-122.26, 37.88

  • Excel formula for distance [km]:

ACOS(SIN(lat1)_SIN(lat2)+COS(lat1)_COS(lat2)_COS(lon2-lon1))_6371

  • Google refine formula [km]:

acos(sin(37.88 * PI/180.) * sin(cells["Latitude"]["value"] * PI/180.) + cos(37.88 * PI/180) * cos(cells["Latitude"]["value"] * PI/180.) * cos((cells["Longitude"]["value"] + 122.26) * PI/180.)) * 6371.

round(value * 10)/10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment