Search code examples
rgoogle-maps-api-3ggmap

Get a Lat/Long from a Neighborhood Name


I have a list of neighborhood names from Rio de Janeiro and would like to get the latitude and longitudes associated with name. Neighborhood Names

When I type any of the names into Google, it responds with a lat/long tuple as seen below.

Googled Neighborhood Name

I'm wondering if there's a programmatic way to do this, as opposed to going through, Googling each neighborhood name, and typing the lat/long for the neighborhood. I suspect there may be a way to do this with ggmap but any guidance would be most appreciated.


Solution

  • library(ggmap)
    geocode("copacabana")
    
    # Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=copacabana&sensor=false
    # lon      lat
    # 1 -79.38823 43.64842