gadm.extract {RWmisc}R Documentation

Extract layers by country from GADM GeoPackage file

Description

Extract one or more levels of administrative unit geometries from the GADM database in GeoPackage format

Usage

gadm.extract(input, output, countries = NULL, level = 0:5, ...)

Arguments

input

GeoPackage file to read from

output

name of file to save output to

countries

country or countries to limit results to, if NULL returns all countries

level

level(s) of administrative units 0:5 to extract; note not all levels are defined for all countries

...

additional arguments passed to sf::st_write()

Details

This function is designed to extract subsets of the Database of Global Administrative Areas (GADM). It uses the version of the database in GeoPackage format that provides one layer for each level of administrative division, available at https://gadm.org/download_world.html. The current version of this file is gadm36_levels.gpkg. It is intended for programmatic and reproducible subsetting of the database without requiring the user to individually download specific country data files.

Examples

## Not run: 
## extract
gadm.extract("gadm36_levels.gpkg", "Nordics.gpkg",
             c("Denmark", "Finland", "Iceland", "Norway", "Sweden"),
             level = 0:2)

## add layers 3 and 4, use delete_layer = TRUE to rewrite existing layers
gadm.extract("gadm36_levels.gpkg", "Nordics.gpkg",
             c("Denmark", "Finland", "Iceland", "Norway", "Sweden"),
             level = 0:4, delete_layer = TRUE)

## End(Not run)

[Package RWmisc version 0.1.2 Index]