Get country shapefile from geoboundaries

get_country_shape(country_iso, admin_level, type = "SSCU", timeout = 2)

Arguments

country_iso

the three letter code corresponding to the country. Use ?popcompr::geoboundaries to see the full list.

admin_level

numeric, the admin level of the shapefile (0 = the country border, then 1, 2, 3). Note that not all admin levels are available

type

the type of shapefile. Geoboundaries have simplified and unsimplified, and standardized vs. unstandardized (and combinations thereof) available for use. See the api documentation for more details: https://www.geoboundaries.org/api.html

timeout

numeric in seconds, the amount of time to wait for the httr request, default is 2, set higher if your connection is slower (max is set to 1 min for safety)

Value

a shapefile as an sf object

Examples

# Defaults to simplified les_simple <- get_country_shape(country_iso = "LSO", admin_level = 2)
#> Reading layer `geoBoundariesSSCU-3_0_0-LSO-ADM2' from data source `https://geoboundaries.org/data/geoBoundariesSSCU-3_0_0/LSO/ADM2/geoBoundariesSSCU-3_0_0-LSO-ADM2.geojson' using driver `GeoJSON' #> Simple feature collection with 78 features and 5 fields #> geometry type: POLYGON #> dimension: XY #> bbox: xmin: 27.01125 ymin: -30.67785 xmax: 29.45737 ymax: -28.57103 #> geographic CRS: WGS 84