Last active
January 14, 2024 12:43
-
-
Save pdbartsch/5987932 to your computer and use it in GitHub Desktop.
open-refine geocoding using OpenStreetMap's Nominatim service. (previously called google-refine)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step One - Starting with a single address field | |
Edit Column > Add Column by Fetching URLs | |
Nominatim has a limit of 1 geocode per second so make sure to set the throttle delay to greater than 1000 milliseconds | |
Fetch URL based on column (quotes needed): | |
"http://nominatim.openstreetmap.org/search?format=json&email=[YOUR_EMAIL_HERE].com&app=google-refine&q=' + escape(value, 'url')" | |
------------------------------------------------------------------------------------ | |
Step Two - Extract lat/lon from newly created JSON blobs | |
Edit Column > Add Column based on This Column | |
Parse Json and concatenate latitude, longitude: | |
with(value.parseJson()[0], pair, pair.lat + ',' + pair.lon) | |
------------------------------------------------------------------------------------ | |
Sources: | |
https://github.com/OpenRefine/OpenRefine/wiki/Geocoding | |
http://wiki.openstreetmap.org/wiki/Nominatim | |
https://gist.github.com/mjrich/3118660 | |
http://www.youtube.com/watch?v=5tsyz3ibYzk&feature=player_embedded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The URL to fetch is a little off—I believe it should be
"http://nominatim.openstreetmap.org/search?format=json&email=[YOUR_EMAIL_HERE]&app=google-refine&q=" + escape(value, 'url')
. Or if you want to include the single quotes around the query value, then"http://nominatim.openstreetmap.org/search?format=json&email=[YOUR_EMAIL_HERE]&app=google-refine&q='" + escape(value, 'url') + "'"
.