我必须对大量的地址进行地理编码(> 100万个地址),因此我可以访问本地的nominatim服务器。但我不知道如何通过R访问这些服务。
可以使用R-package“nominatim”在本地服务器上进行地理编码?当使用osm_geocode函数时,我必须改变哪些参数?
非常感谢提前 多罗
osm_geocode
function (query, country_codes = NULL, viewbox = NULL, bounded = FALSE,
address_details = TRUE, exclude_place_ids = NULL, limit = 1,
email = getOption("OSM_API_EMAIL", "nominatimrpackage@example.com"),
accept_language = getOption("LANG", "en-US,en;q=0.8"), key = getOption("OSM_API_KEY",
""))
{
if (nchar(key) == 0) {
stop("Please provide a openstreet API key")
}
bind_rows(pblapply(1:length(query), function(i) {
param_base <- sprintf("%s/%s", getOption("NOMINATIM.search_base"),
gsub(" ", "+", query[i]))
params <- "format=json&dedupe=0&debug=0&polygon=0"
if (!is.null(country_codes))
params <- sprintf("%s&country_codes=%s", params,
country_codes)
if (!is.null(viewbox))
params <- sprintf("%s&viewbox=%s", params, viewbox)
if (!is.null(bounded))
params <- sprintf("%s&bounded=%d", params, as.numeric(bounded))
if (!is.null(exclude_place_ids))
params <- sprintf("%s&exclude_place_ids=%s", params,
exclude_place_ids)
if (!is.null(email))
params <- sprintf("%s&email=%s", params, curl::curl_escape(email))
if (!is.null(accept_language))
params <- sprintf("%s&accept-language=%s", params,
curl::curl_escape(accept_language))
params <- sprintf("%s&address_details=%d", params, as.numeric(address_details))
params <- sprintf("%s&limit=%d", params, as.numeric(limit))
params <- sprintf("%s&key=%s", params, key)
if (length(query) > 1 & length(query) != i)
Sys.sleep(getOption("NOMINATIM.DELAY"))
.search(param_base, params)
}))