Get roads of Spain

esp_get_roads(
  year = Sys.Date(),
  epsg = "4258",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE,
  moveCAN = TRUE
)

Arguments

year

Release year. See Details for years available.

epsg

projection of the map: 4-digit EPSG code. One of:

  • "4258": ETRS89

  • "4326": WGS84

  • "3035": ETRS89 / ETRS-LAEA

  • "3857": Pseudo-Mercator

cache

A logical whether to do caching. Default is TRUE.

update_cache

A logical whether to update cache. Default is FALSE. When set to TRUE it would force a fresh download of the source .geojson file.

cache_dir

A path to a cache directory. The directory can also be set globally with:

See Details on esp_get_nuts().

verbose

Display information. Useful for debugging, default is FALSE.

moveCAN

A logical TRUE/FALSE or a vector of coordinates c(lat, lon). It places the Canary Islands close to Spain's mainland. Initial position can be adjusted using the vector of coordinates.

Source

IGN data via a custom CDN (see https://github.com/rOpenSpain/mapSpain/tree/sianedata.

Value

A LINESTRING\MULTILINESTRING object.

Details

year could be passed as a single year ("YYYY" format, as end of year) or as a specific date ("YYYY-MM-DD" format).

Details on caching can be found on esp_get_nuts()

Note

While moveCAN is useful for visualization, it would alter the actual geographical position of the Canary Islands.

See also

Author

dieghernan, https://github.com/dieghernan/.

Examples

# \donttest{ library(sf) CyL <- esp_get_prov("Castilla y Leon") Roads <- esp_get_roads() # Intersect roads CyL_Roads <- st_intersection(CyL, Roads)
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
library(tmap) tm_shape(CyL) + tm_polygons(col = "grey80", border.col = "grey50", lwd = 0.4) + tm_shape(CyL_Roads) + tm_lines("tipo", palette = c("#003399", "#003399", "#ff0000", "#ffff00") ) + tm_layout(legend.outside = TRUE, legend.outside.position = "bottom")
# }