gadm: Get GADM data

Description Usage Arguments Details Author(s) Examples

View source: R/gadm.R

Description

Download sp or sf file format from GADM in the internal library of the package and/or a specified path and/or a temporary path.

Usage

1
2
gadm(country, format, level, intlib = TRUE, save = FALSE,
  path = NULL, force = FALSE)

Arguments

country

character string, name of the country to download

format

character string, format to downlaod, either sp or sf

level

integer between 0 and 3 or 4, level of the administrative borders, 0 being country borders.

intlib

boolean, specifies whether the downloaded file should be saved in the library of packages. If NULL, it will be asked interactively. By default TRUE, see 'Details' for more information.

save

boolean, specifies whether the downloaded file should be saved in a specific path or not. If NULL, it will be asked interactively. By default FALSE, see 'Details' for more information.

path

character string, path to save the downloaded file. If NULL, the file will be saved in the working directory. By default NULL, see 'Details' for more information.

force

boolean, force to download the file even if already in the path. By default FALSE.

Details

If the save and/or intlib arguments are NULL, it will be asked interactively to the user to decide where to store the file. The function will return a message if the file is already present in the internal library or in the specify path. The function will only download the file if it's not available in the internal library and the path inputted but the download can be forced (argument force == TRUE) if the file present has a problem.

The table will show you the interaction between these two arguments to download and path to saved sp or sf file format from GADM:
|--intlib = FALSE | |-- save = FALSE | | *-- no disk memory | |-- save = TRUE | | |-- path = NULL | | *-- working directory | | |-- path = PATH | | *-- PATH | |-- save = NULL | | |-- `Do you want to save the map in another location?` | | |-- yes | | |-- `Can you provide the path to the location?` | | | *-- working directory (default) | | | *-- PATH | | |-- no (default) |--intlib = TRUE | |-- save = FALSE | | *-- internal library | |-- save = TRUE | | |-- path = NULL | | *-- internal library + working directory | | |-- path = PATH | | *-- internal library + PATH | |-- save = NULL | | |-- `Do you want to save the map in another location?` | | |-- yes | | |-- `Can you provide the path to the location?` | | | *-- internal library+ working directory (default) | | | *-- internal library+ PATH | | |-- no (default) |--intlib = NULL |-- `Do you want to save the map in your internal library?` *-- no >> intlib = FALSE *-- yes >> intlib = TRUE

Author(s)

Marc Choisy, Lucie Contamin

Examples

1
2
3
4
5
6
7
8
# to download Cambodia country administrative boundaries
kh <- gadm("Cambodia", "sf", 0)

#' # to download Vietnam only in the working directory
## Not run: 
vn <- gadm("Vietnam", "sf", 0, intlib = FALSE, save = TRUE)

## End(Not run)

choisy/sptools documentation built on Aug. 22, 2019, 12:57 p.m.