Skip to contents

Return data from https://opendata.scot/ website. Currently, only datasets in CSV, JSON and GeoJSON formats supported. If data is not available in these formats, a warning is provided. By default data is saved locally to avoid re-downloading on subsequent requests.

Usage

ods_get(
  data = NULL,
  search = NULL,
  refresh = FALSE,
  ask = TRUE,
  type = c("CSV", "GEOJSON", "JSON", "ZIP")
)

Arguments

data

Dataframe from ods_search() or if default (NULL), will download all datasets.

search

Search term(s) if data parameter not provided.

refresh

Refresh cached data. If data has changed remotely, use this to update or renew corrupted data/cache. This will download data again and update the cache.

ask

If FALSE, user will not be prompted for input to download data. This is useful to automate data downloads and cache updated, or speed-up the process if downloading many datasets at once.

type

Character string to filter which filetype to download. Default if more than one datatype available to preference in this order; GEOJSON, CSV, JSON.

Value

list of named data frames. GeoJSON data is converted to simple features sf class to aid spatial analysis.

Examples

search <- ods_search("bins")
#> Creating directory to hold opendatascot data at ~/.local/share/opendatascot
data <- ods_get(search, refresh = TRUE, ask = FALSE)
#> Saving to opendatascot data directory at ~/.local/share/opendatascot
#> Saving to opendatascot data directory at ~/.local/share/opendatascot
#> Saving to opendatascot data directory at ~/.local/share/opendatascot
#> Saving to opendatascot data directory at ~/.local/share/opendatascot
#> Saving to opendatascot data directory at ~/.local/share/opendatascot