knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Two convenience functions are provided that allows address information to be used as basis for a geocoding lookup that can return coordinates. Let's say address information is provided for an institution or institute that is not present in the GRID database.
The following example shows how these geocoding functions can be used to look up geocoding information:
library(institutions) library(dplyr) library(curl) institutions_download(overwrite = TRUE) # using Nominatim API (Open Street Map) osm <- geocode_nominatim("Kungliga Tekniska Högskolan") if (nrow(osm) > 0) { # coordinates etc osm %>% glimpse() osm %>% select(lat, lon) } # # using MapQuest API, requires .Renviron with MAPQUEST_API_KEY env set # if (nchar(Sys.getenv("MAPQUEST_API_KEY")) > 0) { # mq <- # geocode_mapquest( # street = "Kungliga Tekniska Hogskolan", # zip = "100 44", # city = "Stockholm") # # coordinates etc # mq %>% # mutate_at(vars(starts_with("admin")), function(x) iconv(x, to = "iso-8859-1")) %>% # slice(2) %>% # use only the second result # glimpse() # #}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.