Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • New command -opencagegeo- available from SSC

    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:
    Code:
    ssc install opencagegeo
    (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
    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)
    Reverse Geocoding
    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
    Immediate (Forward and Reverse) Geocoding

    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
    For a detailed desciption of -opencagegeo- check the help-file and the pdf documentation which comes as an ancillary file with the package, see:
    Code:
    ssc describe opencagegeo
    Comments and suggestions are welcome!





  • #2
    Dear Lars,
    I received a list with 500 districts and cities in Germany based on registration plates for cars that I need to geocode. I did some test runs by comparing coordinates that were retrieved by opencagegeo and coordinates by www.latitude.to. For geocoding, I used city() (e.g. Rendsburg-Eckernförde, Schleswig-Flensburg). I am really impressed by your ado! It works very well even with these crude information. Do you have any suggestions for calculating distances as well? I used geodist from ssc but I'd rather use travel distances. It appears to me that the ado traveltime from ssc works only for the US(?)
    Thank you!
    Oliver

    Comment


    • #3
      Dear Oliver,

      I suggest that you take a look at the new package georoute we just made available on SSC. See: http://www.statalist.org/forums/foru...eoroute-on-ssc.
      I think this is exactly what you are looking for.
      Best,

      Sylvain

      Comment


      • #4
        Dear Lars,
        Do street modifiers need to be included with the street name? For example, if the address is 14 East Main St, should the street be entered as "East Main" or "East Main St." or "Main" or "Main St." So, this question is about, really, both modifiers as well as street types.
        Thank you,
        Shooshan

        Comment


        • #5
          Dear Lars,
          Many thanks for your opencagegeo command! I want to geocode address. However, I just have the data for subdistrict, municipality and province. I got the API Key, and installed everything. But when I enter "opencagegeo, key subdistrict municipality province ". It doesn't work. And it showed "option key not allowed". Do I have to write other commands before using it?
          Thank you!

          Mengrou

          Comment


          • #6
            Dear Mengrou,

            thanks for your message.

            Please try the following:
            1. Generate a single string variable containing the subdistrict, municipality and province separated by a comma using egen:
            Code:
            egen location = concat(subdistrict municipality province), punct(,)
            2. Run the following code:
            Code:
            opencagegeo, key(YOUR-KEY-HERE) fulladdress(location)
            I hope this helps!

            best
            Lars

            Comment


            • #7
              Dear Lars,

              Many thanks for your help! Can't express my gratefulness to you anymore! This command really saves me and it works after I entered your command.

              Thanks again!

              Best regards!

              Mengrou

              Comment


              • #8
                Dear Lars,

                Thanks for this program. However, I've been trying to get a valid result and haven't been able. I re-shaped my address y multiple ways, and nothing. So then I decided to use as inputs the examples you have in the description, and nothing again.

                Any ideas?

                D


                Example:

                . opencagegeoi Wittenbergerstrasse 14, 26188 Edewecht, Germany
                *********************************
                *** OpenCage Geocoder Results ***
                *********************************
                Formatted address:
                Latitude:
                Longitude:

                Comment


                • #9
                  Hi Lars Zeigermann, I'd like to contact you via email. Which is your current email address? Thank you!

                  Comment

                  Working...
                  X