Function to download administrative boundaries data from the gadm archive, starting from a country name or ISO code, and the level of desired administrative units. The function is a simple wrapper to the raster::getData function, with a-priori checks on country name or ISO code and automatic recasting to sf format.

get_boundaries(iso, level = 1, path = tempdir())

Arguments

iso

character iso name or 2/3 digits code of the country

level

numeric level of administrative units returned, Default: 0 (Country Level)

path

character folder where the "RData" file containing polygon boundaries should be saved, Default: tempdir()

Value

sf object containing the desired data

See also

Examples

library(sprawl) library(sf) ita_boundaries <- get_boundaries("Italy", 0)
#> get_boundaries --> Downloading data for: "Italy", Level: 0
plot_vect(ita_boundaries)
#> Warning: `fill_var` not specified. Only the geometry will be plotted!
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
#> Scale on map varies by more than 10%, scale bar may be inaccurate
ita_region_boundaries <- get_boundaries("ITA", 1)
#> get_boundaries --> Downloading data for: "ITA", Level: 1
plot_vect(ita_region_boundaries, fill_var = "NAME_1")
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
#> Scale on map varies by more than 10%, scale bar may be inaccurate
lomb_boundaries <- ita_region_boundaries %>% dplyr::filter(NAME_1 == "Lombardia") plot_vect(lomb_boundaries)
#> Warning: `fill_var` not specified. Only the geometry will be plotted!
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.