Read-only mirror of https://github.com/ogdtg/tgAPI — Kanton Thurgau. Issues & pull requests at the source.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-05-05 13:34:33 +02:00
man possible to read large geo datasets 2023-06-22 14:52:22 +02:00
R change geo link 2026-05-05 13:34:33 +02:00
sticker possible to download geo data 2023-06-20 13:53:49 +02:00
.gitignore possible to read large geo datasets 2023-06-22 14:52:22 +02:00
.Rbuildignore initial commit 2022-06-13 15:53:47 +02:00
DESCRIPTION change geo link 2026-05-05 13:31:07 +02:00
LICENSE license, exceptions added 2022-06-21 10:55:01 +02:00
LICENSE.md license, exceptions added 2022-06-21 10:55:01 +02:00
NAMESPACE possible to read large geo datasets 2023-06-22 14:52:22 +02:00
NEWS.md license, exceptions added 2022-06-21 10:55:01 +02:00
README.md possible to read large geo datasets 2023-06-22 14:54:52 +02:00
tgAPI.Rproj initial commit 2022-06-13 15:53:47 +02:00

tgAPI

Lifecycle: experimental

The purpose of tgAPI is to enable access to data from the Open Government Data (OGD) portal of the Cantone of Thurgau, Switzerland via API calls.

Release Note 20.06.2023: From now on it is also possible to retrieve geo data from the portal.

Installation

You can install the development version of tgAPI from GitHub with:

# install.packages("devtools")
devtools::install_github("ogdtg/tgAPI")

Example

To explore the available datasets and their corresponding dataset IDs, you can use the get_catalog function.

library(tgAPI)
full_catalog <- get_catalog()

Within the catalog, you can search for the desired dataset and directly obtain the corresponding dataset ID. Once you have the dataset ID, you can export the dataset as a data.frame using the get_dataset function. For instance, to retrieve the dataset "sk-stat-94", you can use the following code:

data <- get_dataset("sk-stat-94")

If you need more information about the labels and their meanings, you can download detailed field descriptions using the get_field_description function.

fields <- get_field_description("sk-stat-94")

Geodata

You can also retrieve geodata by utilizing the dataset ID.

To ensure efficient data retrieval, it is recommended to download one feature at a time instead of all features simultaneously. You can determine the available features by using the get_geo_features command.

features <- get_geo_features("erdwarme")

This will provide you with a dataset containing all the available features. You can then choose a specific feature from which you wish to retrieve the data and download it using the get_geo_data function.

Larger Geodata will be downloaded in slices of 1000 features per request, to avoid memory overload.

geo_data <- get_geo_data(dataset_id = "erdwarme", feature = "Erdwärmesondenbohrungen")

Alternatively, you can download all features at once by setting `feature = "all". However, please be aware that this may result in a substantial amount of data and a longer download time. Therefore, this option is recommended only for specific use cases.