download_os_opendata {osdatahub}R Documentation

Download OS OpenData Products

Description

Main function for downloading OS open data product files to your local machine.

Usage

download_os_opendata(product, ...)

## S3 method for class 'product_list'
download_os_opendata(
  product,
  file_name,
  file_format,
  area,
  output_dir,
  overwrite = FALSE,
  ...
)

## S3 method for class 'character'
download_os_opendata(
  product,
  file_name,
  file_format,
  file_subformat,
  area,
  output_dir,
  overwrite = FALSE,
  ...
)

Arguments

product

A product_list object retrieved and filtered using list_os_opendata. Alternatively, a data product name as a character string.

...

Additional parameters. Not currently used.

file_name

(character) Filter downloads to only include those with this file name. Optional.

file_format

(character) Filter downloads to only include those with this format. Optional.

area

(character) Filter downloads for only this area. Use 'GB' for all Great Britain. Optional.

output_dir

Path to the directory where the downloaded files will be saved.

overwrite

Boolean. Should existing files be overwritten? Default is FALSE.

file_subformat

(character) Filter downloads to only include those with this subformat. Optional and only used when product is a character string.

Details

The OS Downloads API assists with the discovery and download of OS OpenData and OS Premium data packages. This function is used as the main step to download open data products to your local machine. It is designed to work best after list_os_opendata is first used to search and filter for the specific download product. The product_list returned by the listing step can be used as the input value to download the desired files. Alternatively, it is possible to supply a product name and filtering options based on file formats and areas.

The optional area filter is based on two-letter British National Grid tiles. Use 'GB' for all of Great Britain. Valid values area: GB, HP, HT, HU, HW, HX, HY, HZ, NA, NB, NC, ND, NF, NG, NH, NJ, NK, NL, NM, NN, NO, NR, NS, NT, NU, NW, NX, NY, NZ, OV, SD, SE, TA, SH, SJ, SK, TF, TG, SM, SN, SO, SP, TL, TM, SR, SS, ST, SU, TQ, TR, SV, SW, SX, SY, SZ, TV.

For more information on the Downloads API, see https://osdatahub.os.uk/docs/downloads/technicalSpecification.

Value

Silently returns the directory where the downloaded files are stored.

See Also

list_os_opendata()

Examples


# Search and filter available open products.
prod_list <- list_os_opendata('OpenGreenSpace',
                              file_format = 'GeoPackage',
                              area = 'GB')

# Use the product list to initiate a download.
download_os_opendata(prod_list, output_dir = tempdir())

# Combine search and download.
# Be sure to know the products to avoid downloading more data than desired.
download_os_opendata(product = 'OpenGreenSpace',
                     file_format = 'GeoPackage',
                     area = 'GB',
                     output_dir = tempdir())



[Package osdatahub version 0.2.0 Index]