Learn R Programming

mapSpain (version 0.1.2)

esp_get_can_box: Get complementary lines when plotting Canary Islands.

Description

When plotting Spain, it is usual to represent the Canary Islands as an inset (see moveCAN on esp_get_nuts). These functions provides complementary borders when Canary Islands are displaces.

esp_get_can_box is used to draw lines around the displaced Canary Islands.

esp_get_can_provinces is used to draw a separator line between the two provinces of the Canary Islands.

Usage

esp_get_can_box(style = "right", moveCAN = TRUE, epsg = "4258")

esp_get_can_provinces(moveCAN = TRUE, epsg = "4258")

Arguments

style

Style of line around Canary Islands. Four options available: 'left', 'right', 'box' or 'poly'.

moveCAN, epsg

Value

A LINESTRING or POLYGON object if style = 'poly'.

esp_get_can_provinces returns a LINESTRING object.

See Also

esp_get_nuts, esp_get_ccaa.

Examples

Run this code
# NOT RUN {
library(sf)

Provs <-  esp_get_prov()
Box <- esp_get_can_box()
Line <- esp_get_can_provinces()


plot(st_geometry(Provs), col = hcl.colors(4, palette = "Grays"))
plot(Box, add = TRUE)
plot(Line, add = TRUE)


# Displacing Canary

Provs_D <-  esp_get_prov(moveCAN = c(15, 0))
Box_D <- esp_get_can_box(style = "left", moveCAN = c(15, 0))
Line_D <- esp_get_can_provinces(moveCAN = c(15, 0))



plot(st_geometry(Provs_D), col = hcl.colors(4, palette = "Grays"))
plot(Box_D, add = TRUE)
plot(Line_D, add = TRUE)

# Example with poly option

library(giscoR)

Countries <-
  gisco_get_countries(res = "20",
                      epsg = "4326",
                      region = c("Europe", "Africa"))
CANbox <-
  esp_get_can_box(style = "poly",
                  epsg = "4326",
                  moveCAN = c(12.5, 0))
CCAA <- esp_get_ccaa(res = "20",
                     epsg = "4326",
                     moveCAN = c(12.5, 0))


plot_sf(CCAA, axes = TRUE)
plot(st_geometry(Countries), col = "grey80", add = TRUE)
plot(st_geometry(CANbox),
     border = "black",
     col = "white",
     add = TRUE)
plot(st_geometry(CCAA), add = TRUE, col = "beige")
box()
# }

Run the code above in your browser using DataLab