Geographic Information Systems Asked by Adrian Dobra on December 23, 2020
I need to find a package in R or source code in R that performs batch geocoding using Bing, Yahoo, OpenStreetMap. Do you have any suggestions?
API conditions constantly change, but this should work right now.
OSM:
devtools::install_github("hrbrmstr/nominatim")
library(nominatim)
b1 <- osm_geocode("Berlin, Germany")
b1[c("lat", "lon")]
Yahoo:
devtools::install_github("trestletech/rydn")
library(rydn)
options(RYDN_KEY="yourAPIkey", RYDN_SECRET="yourSecret")
b2 <- find_place("Berlin, Germany")
b2[c("latitude", "longitude")]
Bing: taRifx.geo (works with Google) and supposedly works with Bing, but I could never get it to work, so I wrote my own function.
bGeoCode <- function(str, BingMapsKey){
require(RCurl)
require(RJSONIO)
u <- URLencode(paste0("http://dev.virtualearth.net/REST/v1/Locations?q=", str, "&maxResults=1&key=", BingMapsKey))
d <- getURL(u)
j <- fromJSON(d,simplify = FALSE)
if (j$resourceSets[[1]]$estimatedTotal > 0) {
lat <- j$resourceSets[[1]]$resources[[1]]$point$coordinates[[1]]
lng <- j$resourceSets[[1]]$resources[[1]]$point$coordinates[[2]]
}
else {
lat <- lng <- NA
}
c(lat,lng)
}
bGeoCode("Berlin, Germany", "yourAPIkey")
Google:
library(ggmap)
register_google(key = "yourAPIkey")
geocode("Berlin, Germany", source="google")
Answered by cengel on December 23, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP