View source: R/add_coordinates.R
add_coordinates | R Documentation |
Adds/Retrieves longitude/latitude values to location data within an epiflows object.
Coordinates are added to object's locations slot as lon
and lat
columns.
add_coordinates(
x,
coordinates = c("lon", "lat"),
loc_column = "id",
overwrite = FALSE
)
get_coordinates(x, ...)
## S3 method for class 'epiflows'
get_coordinates(x, location = NULL, ...)
x |
An |
coordinates |
Either names of the appended columns with longitudes and latitudes, respectively (default: "lon" and "lat") or a data frame with longitude and latitude columns. |
loc_column |
Name of the column where location names are stored (default: "country"). |
overwrite |
If TRUE, retrieves all geocodes, even those already retrieved. If FALSE (default), overwrites only NAs. |
... |
unused |
location |
a character specifying a single location to return as a vector of coordinates. You cannot specify multiple locations with this parameter. Defaults to 'NULL', indicating all locations. |
An updated epiflows
object.
Pawel Piatkowski, Salla Toikkanen, Zhian Kamvar
map_epiflows()
; plot.epiflows()
; get_locations()
; get_vars()
;
global_vars()
# Setting up the data
data("Brazil_epiflows")
data("YF_coordinates")
get_coordinates(Brazil_epiflows) # no coordinates yet
ef <- add_coordinates(Brazil_epiflows, YF_coordinates[-1])
get_coordinates(ef)
get_coordinates(ef, location = "Espirito Santo") # coordinates for Espirito Santo
if (interactive()) {
# You can use google maps' geocode functionality if you have a decent
# internet connection
# NOTE: you may need to authenticate with Google Maps API beforehand
# using ggmap::register_google()
ef2 <- add_coordinates(Brazil_epiflows, loc_column = "id")
ef2
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.