# NOT RUN {
getbb("Salzburg")
place_name <- "Hereford"
getbb(place_name, silent = FALSE)
# return bb whose display_name contain text string "United States"
getbb(place_name, display_name_contains = "United States", silent = FALSE)
# top 3 matches as data frame
getbb(place_name, format_out = "data.frame", limit = 3)
# Examples of polygonal boundaries
bb <- getbb ("london uk", format_out = "polygon") # single match
dim(bb) # matrix of longitude/latitude pairs
plot(bb)
# Multiple matches return a nested list of matrices:
bb <- getbb ("london", format_out = "polygon")
sapply(bb, length) # 5 lists returned
bbmat = matrix(unlist(bb), ncol = 2)
plot(bbmat) # worldwide coverage of places called "london"
# Using an alternative service (locationiq requires an API key)
key <- Sys.getenv("LOCATIONIQ") # add LOCATIONIQ=type_your_api_key_here to .Renviron
if(nchar(key) == 32) {
getbb(place_name, base_url = "http://locationiq.org/v1/search.php", key = key)
}
# }
Run the code above in your browser using DataLab