Skip to contents

downlaod_ban() is used has a wrapper of download_archive() to download easily BAN database.

Usage

download_ban(
  destination,
  repository = c("data.gouv", "other"),
  origin = NULL,
  extension = NULL,
  date = NULL,
  version = c("ban", "bal"),
  department = NULL,
  region = NULL,
  verbose = TRUE
)

Arguments

destination

character, the address where data are stocked.

repository

character, keyword or the repository from where data are downloaded. Best to use given options. See details.

origin

character, url address from where data are downloaded. It is set when repository is something else than "other".

extension

character, vector of acceptable types of archive to be downloaded.

date

character, date of the archive to be downloaded.

version

string, version of BAN to be downloaded. See details.

department

integer, or converted to integer. Departments that should be considered. See details.

region

integer, or converted to integer. Regions that should be considered. See details.

verbose

logical, should the function send some messages while running.

Value

An invisible data.frame of log.

Details

If repository is set to "data.gouv", then all necessary variables are filled with those values:

  • origin is set to "https://adresse.data.gouv.fr/data/ban/adresses"

  • name default value is changed to "adresses"

  • extension default value is changed to "csv.gz"

  • date default value is used to choose a given directory. If date is NULL, then the most recent version is taken (equivalent to "latest").

  • version must be something within "ban" or "bal". When "ban" is used the file with one position per address is used. When "bal" is used, the file with several position per address is used.

  • department is used. Should be admissible French departments (a formatting will be attempted with format_scope()). If NULL, region may be used. If both are NULL, all departments from `floodam.data::department`` will be used.

  • region may be used if department is NULL. Should be admissible French regions (a formatting will be attempted with format_scope()). If region is given and department is NULL, all departments from given region will be used.

If repository is set to "other", everything shall be filled so that download_archive() can make a successful download.

Examples

if (FALSE) {
dest = tempdir()
download_ban(dest)
download_ban(dest, department = 34)
download_ban(dest, department = 34, date = "2022-01-01")
download_ban(dest, region = 76, date = "2022-01-01")
download_ban(dest, department = 976, date = "2022-09-20", version = "bal")

unlink(dest)
}