Dear Statalisters,
Thanks to Kit Baum, -opencagegeo-, a new geocoding module for Stata, is available for download.
-opencagegeo- uses the OpenCage Geocoder API which, in turn, uses OpenStreetMap (OSM) and other open data sources. Its major advantage over other geocoders for stata (using Google Maps, MapQuest and HERE Maps) is the flexible terms of use: geocodes may be stored and their use is not restricted. Even commercial use is explicitly permitted. See https://geocoder.opencagedata.com/faq#legal.
An OpenCage Geocoder API key is required and can be requested free of charge from https://geocoder.opencagedata.com/ . It allows 2.500 calls per 24h (different customer plans for larger volumes are available).
To install opencagegeo, type:
(Note: -opencagegeo- requires -insheetjson- and -libjson- written by Erik Lindsley, which are available from SSC)
The following three examples demonstrate how -opencagegeo- and its immediate version -opencagegeoi- are used.
Forward Geocoding
Reverse Geocoding
Immediate (Forward and Reverse) Geocoding
For geocoding a single location, one can also use the immediate version -opencagegeoi-:
For a detailed desciption of -opencagegeo- check the help-file and the pdf documentation which comes as an ancillary file with the package, see:
Comments and suggestions are welcome!
Thanks to Kit Baum, -opencagegeo-, a new geocoding module for Stata, is available for download.
-opencagegeo- uses the OpenCage Geocoder API which, in turn, uses OpenStreetMap (OSM) and other open data sources. Its major advantage over other geocoders for stata (using Google Maps, MapQuest and HERE Maps) is the flexible terms of use: geocodes may be stored and their use is not restricted. Even commercial use is explicitly permitted. See https://geocoder.opencagedata.com/faq#legal.
An OpenCage Geocoder API key is required and can be requested free of charge from https://geocoder.opencagedata.com/ . It allows 2.500 calls per 24h (different customer plans for larger volumes are available).
To install opencagegeo, type:
Code:
ssc install opencagegeo
The following three examples demonstrate how -opencagegeo- and its immediate version -opencagegeoi- are used.
Forward Geocoding
Code:
set obs 2 gen STREET = "Wittenbergerstrasse" in 1 replace STREET = "Denkmalsplatz" in 2 gen HOUSENUMBER = "14" in 1 gen POSTCODE = "26188" in 1 replace POSTCODE = "26180" in 2 gen CITY = "Edewecht" in 1 replace CITY = "Rastede" in 2 opencagegeo, key(YOUR-KEY-HERE) street(STREET) number(HOUSENUMBER) city(CITY)
Code:
gen LATITUDE = "53.1479943" in 1 replace LATITUDE = "53.2450876" in 2 gen LONGITUDE = "7.8664466" in 1 replace LONGITUDE = "8.1992326" in 2 opencagegeo, key(YOUR-KEY-HERE) latitude(LATITUDE) longitude(LONGITUDE) replace
For geocoding a single location, one can also use the immediate version -opencagegeoi-:
Code:
global mykey YOUR-KEY-HERE opencagegeoi Wittenbergerstrasse 14, 26188 Edewecht, Germany opencagegeoi 53.1479943,7.8664466
Code:
ssc describe opencagegeo
Comment