Skip to contents

Attribution is required for all uses of this dataset.

These functions are wrappers around gb_get() for extracting a given administrative level. gb_get_adm0() returns the country boundary, gb_get_adm1() returns first-level subnational boundaries (e.g. states in the United States), gb_get_adm2() returns second-level subnational boundaries (e.g. counties in the United States), gb_get_adm3() returns third-level administrative boundaries (e.g. towns or cities in some countries), gb_get_adm4() returns fourth-level administrative boundaries and gb_get_adm5() returns fifth-level administrative boundaries.

Note that not all countries have the same number of levels. Check gb_get_max_adm_lvl().

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
)

Source

geoBoundaries API service https://www.geoboundaries.org/api.html.

Arguments

country

A character vector of country codes. It can be either "all" (which returns the data for all countries), a vector of country names or ISO 3166-1 alpha-3 country codes. See also countrycode::countrycode().

simplified

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

release_type

One of "gbOpen", "gbHumanitarian" or "gbAuthoritative". For most users, we suggest using "gbOpen" (the default), as it is CC BY 4.0 compliant and suitable for most purposes so long as attribution is provided. "gbHumanitarian" files are mirrored from UN OCHA and may have less open licensure. "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 file.

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 will be stored in the temporary directory. See base::tempdir() and caching strategies in gb_set_cache_dir().

Value

A sf object.

Details

Individual country files in the geoBoundaries database are governed by the license or licenses identified within the metadata for each respective boundary. See gb_get_metadata(). Users of individual boundary files from geoBoundaries should also cite the sources provided in the metadata for each file.

References

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

See also

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"
  )

# }