I had a script in order to get coordinates of places, that i was then plotting on a map. to do so, I used the script developed here : https://lrouviere.github.io/TUTO_VISU/faire-des-cartes-avec-r.html
if (!(require(jsonlite))) install.packages("jsonlite")
mygeocode <- function(adresses){
nominatim_osm <- function(address = NULL){
## details: http://wiki.openstreetmap.org/wiki/Nominatim
## fonction nominatim_osm proposée par D.Kisler
if(suppressWarnings(is.null(address))) return(data.frame())
tryCatch(
d <- jsonlite::fromJSON(
gsub('\\@addr\\@', gsub('\\s+', '\\%20', address),
'http://nominatim.openstreetmap.org/search/@addr@?format=json&addressdetails=0&limit=1')
), error = function(c) return(data.frame())
)
if(length(d) == 0) return(data.frame())
return(c(as.numeric(d$lon), as.numeric(d$lat)))
}
tableau <- t(sapply(adresses,nominatim_osm))
colnames(tableau) <- c("lon","lat")
return(tableau)
}
Everything was working perfectly, i could have great maps
But since yesterday, it does not work anymore. when i try to do a geocode such as mygeocode("Rennes")
it tells me that the d is not found (whereas it used to give : lon lat
Rennes -1.68002 48.11134)
I updated the packages, i do not understand what happened. it literally changed while i was using the script, and suddenly i could not produce maps anymore
any idea ?
thanks a lot !