IVIM
IVIM

Reputation: 2367

Automating extraction of latitude, longitude and other information about places from Google

If you type https://www.google.ca/maps/search/Southern+Saskatchewan in your internet browser, Google will conveniently (and automatically!) redirect you to: https://www.google.ca/maps/search/Southern+Saskatchewan/@54.1966035,-115.5094433,5z/data=!3m1!4b1

From there you can see and manually copy and paste the latitude (47.0159646), longitude (-65.6188287) and some other information (5z/data=!3m1!4b1 - I'm not sure what it is) about this region (Southern Saskatchewan).

Is there a way to automate this process somehow - so that such information can be retrieved with R function retrievePlaceInfoFromGoogle <- function(strPlaceName) ?

Maybe with httr or rvest or any any web technology package?

Upvotes: 1

Views: 453

Answers (1)

MihaiV
MihaiV

Reputation: 157

Any attempt to use Google other than the "official" way is going to be blocked and you will get the "unusual traffic detected notification" and tested if you are a human by choosing traffic lights for example.
The official way for geocoding is through the google API. Once you have an api key you could use the googleway package for example:

require(googleway)
set_key("your_google_key_of_39_characters")
x= google_geocode(address = "Southern Saskatchewan", simplify = TRUE)
x$results$geometry

Upvotes: 2

Related Questions