View source: R/esp_get_hydrobasin.R
| esp_get_hydrobasin | R Documentation | 
sf POLYGON of the drainage basin demarcations of SpainLoads a sf POLYGON object containing areas with the required
hydrographic elements of Spain.
esp_get_hydrobasin(
  epsg = "4258",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE,
  resolution = "3",
  domain = "land"
)
| epsg | projection of the map: 4-digit EPSG code. One of: 
 | 
| cache | A logical whether to do caching. Default is  | 
| update_cache | A logical whether to update cache. Default is  | 
| cache_dir | A path to a cache directory. See About caching. | 
| verbose | Logical, displays information. Useful for debugging,
default is  | 
| resolution | Resolution of the  | 
| domain | Possible values are  | 
Metadata available on https://github.com/rOpenSpain/mapSpain/tree/sianedata/.
A sf POLYGON object.
You can set your cache_dir with esp_set_cache_dir().
Sometimes cached files may be corrupt. On that case, try re-downloading
the data setting update_cache = TRUE.
If you experience any problem on download, try to download the
corresponding .geojson file by any other method and save it on your
cache_dir. Use the option verbose = TRUE for debugging the API query.
IGN data via a custom CDN (see https://github.com/rOpenSpain/mapSpain/tree/sianedata).
Other natural: 
esp_get_hypsobath(),
esp_get_rivers()
hydroland <- esp_get_hydrobasin(domain = "land")
hydrolandsea <- esp_get_hydrobasin(domain = "landsea")
library(ggplot2)
ggplot(hydroland) +
  geom_sf(data = hydrolandsea, fill = "skyblue4", alpha = .4) +
  geom_sf(fill = "skyblue", alpha = .5) +
  geom_sf_text(aes(label = rotulo),
    size = 3, check_overlap = TRUE,
    fontface = "bold",
    family = "serif"
  ) +
  coord_sf(
    xlim = c(-9.5, 4.5),
    ylim = c(35, 44)
  ) +
  theme_void()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.