Learn R Programming

mapSpain (version 0.6.1)

esp_get_grid_BDN: Get sf polygons of the national geographic grids provided by BDN

Description

Loads a sf polygon with the geographic grids of Spain as provided on the Banco de Datos de la Naturaleza (Nature Data Bank), by the Ministry of Environment (MITECO):

Usage

esp_get_grid_BDN(
  resolution = 10,
  type = "main",
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE
)

esp_get_grid_BDN_ccaa( ccaa, update_cache = FALSE, cache_dir = NULL, verbose = FALSE )

Arguments

resolution

Resolution of the grid in kms. Could be 5 or 10.

type

The scope of the grid. It could be mainland Spain ("main") or the Canary Islands ("canary").

update_cache

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

cache_dir

A path to a cache directory. See About caching.

verbose

Logical, displays information. Useful for debugging, default is FALSE.

ccaa

A vector of names and/or codes for autonomous communities. See Details on esp_get_ccaa().

Value

A sf polygon

About caching

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.

See Also

esp_get_ccaa()

Other grids: esp_get_grid_EEA(), esp_get_grid_ESDAC(), esp_get_grid_MTN()

Examples

Run this code
# NOT RUN {
grid <- esp_get_grid_BDN(resolution = "10", type = "main")

library(ggplot2)

ggplot(grid) +
  geom_sf() +
  theme_light() +
  labs(title = "BDN Grid for Spain")
# }

Run the code above in your browser using DataLab