J'ai besoin de trouver un package en R ou du code source en R qui effectue le géocodage par lots à l'aide de Bing, Yahoo, OpenStreetmap. Avez-vous des suggestions?
J'ai besoin de trouver un package en R ou du code source en R qui effectue le géocodage par lots à l'aide de Bing, Yahoo, OpenStreetmap. Avez-vous des suggestions?
Réponses:
Les conditions de l'API changent constamment, mais cela devrait fonctionner dès maintenant.
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 (fonctionne avec Google) et fonctionne soi-disant avec Bing, mais je n'ai jamais pu le faire fonctionner, j'ai donc écrit ma propre fonction.
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", "yourAPIKeyHere")Google :
library(ggmap)  
geocode("Berlin, Germany", source="google")