| Title: | Access Data from 'GISCO' |
|---|---|
| Description: | Access data related to the European union from 'GISCO' <https://ec.europa.eu/eurostat/web/gisco>, the Geographic Information System of the European Commission, via its rest API at <https://gisco-services.ec.europa.eu>. This package tries to make it easier to get these data into R. |
| Authors: | Vilmos Prokaj [aut, cre] |
| Maintainer: | Vilmos Prokaj <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.3 |
| Built: | 2026-06-09 06:05:14 UTC |
| Source: | https://github.com/cranhaven/cranhaven.r-universe.dev |
This function retrieves the content from the API and saves it to a file if 'save_to_file' is TRUE.
get_content( api, end_point, save_to_file = FALSE, dest = if (save_to_file) fs::path_file(end_point) else NULL )get_content( api, end_point, save_to_file = FALSE, dest = if (save_to_file) fs::path_file(end_point) else NULL )
api |
An endpoint to the dataset. |
end_point |
A character vector of the endpoint to retrieve content from. |
save_to_file |
A logical value indicating whether to save the content to a file |
dest |
A character vector specifying the destination file path. If 'save_to_file' is TRUE, this should be a valid file path. |
A 'httr2' response object. The content retrieved from the API is either the 'body' of response or the path to the file when 'save_to_file' is TRUE.
api <- get_topic("Postal") files <- get_latest_files(api)$csv file_to_download <- grep("_4326", files, value=TRUE) response <- get_content( api, file_to_download, save_to_file = TRUE, dest = fs::file_temp(ext = "csv") ) response$bodyapi <- get_topic("Postal") files <- get_latest_files(api)$csv file_to_download <- grep("_4326", files, value=TRUE) response <- get_content( api, file_to_download, save_to_file = TRUE, dest = fs::file_temp(ext = "csv") ) response$body
This function retrieves the content length of a file to be downloaded from the API.
get_content_length(api, file_to_download)get_content_length(api, file_to_download)
api |
An endpoint to the dataset variants. |
file_to_download |
A character vector of file names to download. |
An integer vector of content lengths, named by the file names.
api <- get_topic("Postal") files <- get_latest_files(api)$csv purrr::map( files, get_content_length, api = api) |> tibble::as_tibble()api <- get_topic("Postal") files <- get_latest_files(api)$csv purrr::map( files, get_content_length, api = api) |> tibble::as_tibble()
This function returns the list of available datasets as a tibble. The columns of the tibble provide information about each dataset.
get_datasets(api)get_datasets(api)
api |
An endpoint |
A tibble of available datasets.
get_topic("Coastal lines") |> get_datasets()get_topic("Coastal lines") |> get_datasets()
This function retrieves the files belonging to the latest version of the given dataset. When the dataset is not updated the cached version is returned.
get_latest_files(api)get_latest_files(api)
api |
An endpoint to the dataset. |
A named list of files.
get_latest_files(get_topic("Postal"))$csvget_latest_files(get_topic("Postal"))$csv
This function fetches the details of a specific topic based on the provided topic name.
get_topic(topic)get_topic(topic)
topic |
A string representing the topic to retrieve. |
A request object to the specific endpoint.
get_topic("Coastal lines") get_topic("Postal")get_topic("Coastal lines") get_topic("Postal")
Retrieves a list of topics from the specified API endpoint 'https://gisco-services.ec.europa.eu/distribution/v2/'.
get_topics()get_topics()
This function sends a request to the given API endpoint and parses the response to extract topic information.
A tibble the topics retrieved from the API.
# Retrieve topics from the default endpoint topics <- get_topics()# Retrieve topics from the default endpoint topics <- get_topics()