Loads a simple feature (sf) object containing lines or areas with the required hydrograpic elements of Spain.

esp_get_rivers(
  epsg = "4258",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE,
  resolution = "3",
  spatialtype = "line",
  name = NULL
)

Arguments

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.

resolution

Resolution of the polygon. Values available are "3", "6.5" or "10".

spatialtype

Spatial type of the output. Use "area" for POLYGONS or "line" for LINESTRING.

name

Optional. A character or regex expresion with the name of the element to be extracted. See Details

Source

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

Value

A POLYGON or LINESTRING object.

Details

Metadata available on https://github.com/rOpenSpain/mapSpain/tree/sianedata/.

name admits regex expressions. See help("regex", package = "base") for more information.

Author

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

Examples

# \donttest{ # This code would produce a nice plot - It will take a few seconds to run library(sf) # Use of regex regex1 <- esp_get_rivers(name = "Tajo|Segura") unique(regex1$rotulo)
#> [1] "Río Tajo" "Río Segura" #> [3] "Canal del Transvase Tajo-Segura"
regex2 <- esp_get_rivers(name = "Tajo$| Segura") unique(regex2$rotulo)
#> [1] "Río Tajo" "Río Segura"
# Rivers in Spain shapeEsp <- esp_get_country(moveCAN = FALSE) MainRivers <- esp_get_rivers(name = "Tajo$|Ebro$|Ebre$|Duero|Guadiana$|Guadalquivir") opar <- par(no.readonly = TRUE) par(mar = c(0, 0, 0, 0)) plot(st_geometry(MainRivers), col = "skyblue", lwd = 1.5)
plot(st_geometry(shapeEsp), col = NA, add = TRUE)
# All wetlands Wetlands <- esp_get_rivers(spatialtype = "area") plot(st_geometry(Wetlands), col = "skyblue", border = NA)
plot(st_geometry(shapeEsp), col = NA, add = TRUE)
par(opar) # }