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

get_ods(data = NULL, search = NULL, refresh = FALSE, ask = TRUE)

Arguments

data

Dataframe from search_ods() 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.

Value

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

Examples

search <- search_ods("Grit bins")
#> You searched for: `Grit bins`. No dataset titles contain that search term
data <- get_ods(search, refresh = TRUE, ask = FALSE)
#> Error in get_ods(search, refresh = TRUE, ask = FALSE): data must have more than one row