| esp_move_can | R Documentation |
sf object located in the Canary IslandsHelper function to displace an external sf object (potentially
representing a location in the Canary Islands) to align it with the objects
provided by sf with the option moveCAN = TRUE.
esp_move_can(x, moveCAN = TRUE)
x |
An |
moveCAN |
A logical |
This is a helper function that intends to ease the representation of objects located in the Canary Islands that have been obtained from other sources rather than the package mapSpain.
A sf object of the same class and same CRS as x
but displaced accordingly.
While moveCAN is useful for visualization, it will alter the actual
geographic position of the Canary Islands. When using the output for
spatial analysis or using tiles (e.g. with esp_get_tiles() or
addProviderEspTiles()) this option should be set to FALSE in order to
get the actual coordinates, instead of the modified ones.
Other helpers for the Canary Islands:
esp_get_can_box()
library(sf)
teide <- data.frame(
name = "Teide Peak",
lon = -16.6437593,
lat = 28.2722883
)
teide_sf <- st_as_sf(teide, coords = c("lon", "lat"), crs = 4326)
# If we use any mapSpain produced object with moveCAN = TRUE...
esp <- esp_get_spain(moveCAN = c(13, 0))
library(ggplot2)
ggplot(esp) +
geom_sf() +
geom_sf(data = teide_sf, color = "red") +
labs(
title = "Canary Islands displaced",
subtitle = "But not the external Teide object"
)
# But we can
teide_sf_disp <- esp_move_can(teide_sf, moveCAN = c(13, 0))
ggplot(esp) +
geom_sf() +
geom_sf(data = teide_sf_disp, color = "red") +
labs(
title = "Canary Islands displaced",
subtitle = "And also the external Teide object"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.