Skip to contents

These functions wrap gb_get() for a single ADM level. gb_get_adm0() returns country boundaries, gb_get_adm1() returns first-level subnational boundaries (for example, states in the United States) and gb_get_adm2() returns second-level subnational boundaries (for example, counties in the United States). gb_get_adm3(), gb_get_adm4() and gb_get_adm5() return third-, fourth- and fifth-level administrative boundaries, respectively.

Not all countries have the same number of ADM levels. Use gb_get_max_adm_lvl() to check availability.

Attribution is required whenever these data are used.

Usage

gb_get_adm0(
  country,
  simplified = FALSE,
  release_type = c("gbOpen", "gbHumanitarian", "gbAuthoritative"),
  quiet = TRUE,
  overwrite = FALSE,
  cache_dir = NULL
)

gb_get_adm1(
  country,
  simplified = FALSE,
  release_type = c("gbOpen", "gbHumanitarian", "gbAuthoritative"),
  quiet = TRUE,
  overwrite = FALSE,
  cache_dir = NULL
)

gb_get_adm2(
  country,
  simplified = FALSE,
  release_type = c("gbOpen", "gbHumanitarian", "gbAuthoritative"),
  quiet = TRUE,
  overwrite = FALSE,
  cache_dir = NULL
)

gb_get_adm3(
  country,
  simplified = FALSE,
  release_type = c("gbOpen", "gbHumanitarian", "gbAuthoritative"),
  quiet = TRUE,
  overwrite = FALSE,
  cache_dir = NULL
)

gb_get_adm4(
  country,
  simplified = FALSE,
  release_type = c("gbOpen", "gbHumanitarian", "gbAuthoritative"),
  quiet = TRUE,
  overwrite = FALSE,
  cache_dir = NULL
)

gb_get_adm5(
  country,
  simplified = FALSE,
  release_type = c("gbOpen", "gbHumanitarian", "gbAuthoritative"),
  quiet = TRUE,
  overwrite = FALSE,
  cache_dir = NULL
)

Arguments

country

A character vector of country names or ISO 3166-1 alpha-3 country codes. Use "all" to return data for all countries. See also countrycode::countrycode().

simplified

Logical. If TRUE, return simplified boundaries. The default FALSE uses the primary geoBoundaries file. See simplified boundaries at https://www.geoboundaries.org/.

release_type

One of "gbOpen", "gbHumanitarian" or "gbAuthoritative". For most users, use "gbOpen" (the default), which is CC BY 4.0 compliant and suitable for most purposes when attribution is provided. "gbHumanitarian" files are mirrored from UN OCHA and may have less open licensing. "gbAuthoritative" files are mirrored from UN SALB, verified through in-country processes and cannot be used for commercial purposes.

quiet

Logical. If TRUE, suppress informational messages.

overwrite

Logical. If TRUE, force a fresh download of the source .zip archive.

cache_dir

A path to a cache directory. If not set (the default NULL), the data will be stored in the default cache directory (see gb_set_cache_dir()). If no cache directory has been set, files are stored in a temporary cache directory. See base::tempdir() and the cache strategies in gb_set_cache_dir().

Value

An sf object containing the requested boundaries.

Details

Each individual country file is governed by the license identified in its boundary metadata. See gb_get_metadata(). Users should also cite the sources listed in the boundary metadata for each file.

References

Runfola et al. (2020) geoBoundaries: A global database of political administrative boundaries. PLOS ONE 15(4), e0231866. doi:10.1371/journal.pone.0231866 .

Examples

# \donttest{
lev2 <- gb_get_adm2(
  c("Italia", "Suiza", "Austria"),
  simplified = TRUE
)

library(ggplot2)

ggplot(lev2) +
  geom_sf(aes(fill = shapeGroup)) +
  labs(
    title = "Second-level administrative boundaries",
    subtitle = "Selected countries",
    caption = "Source: www.geoboundaries.org"
  )

# }