Package 'ratatouille'

Title: Fetch Rat and Species Management Data from the RATO or Provincial Databases
Description: This repository contains the functionality to access the unprocessed species management data of RATO vzw or the province of West Flanders via an API call to an ESRI ArcGIS instance. Credentials are required to access this data.
Authors: Pieter Huybrechts [aut, cre] (ORCID: <https://orcid.org/0000-0002-6658-6062>), Damiano Oldoni [ctb] (ORCID: <https://orcid.org/0000-0003-3445-7562>), Lien Reyserhove [ctb] (ORCID: <https://orcid.org/0000-0001-7484-9267>), Peter Desmet [ctb] (ORCID: <https://orcid.org/0000-0002-8442-8025>)
Maintainer: Pieter Huybrechts <[email protected]>
License: MIT + file LICENSE
Version: 1.0.4.9000
Built: 2026-10-09 10:26:55 UTC
Source: https://github.com/inbo/ratatouille

Help Index


Get default resource path for a given source

Description

ArcGIS Enterprise allows queries based on the layerOrTableId, this function returns a default resource to query.

Usage

get_default_resource(source = NULL)

Arguments

source

Character string of the source to look up the default resource for. Either "rato" or "wfl".

Value

Character string of the default resource path corresponding to the specified source.

Examples

get_default_resource("rato")

Get objects from an ArcGIS Enterprise environment via the REST API

Description

This function retrieves objects from an ArcGIS environment based on the object_id. It is capable of retrieving a large amount of objects in a single function call. As to minimize errors it will fetch ⁠batch size⁠ number of objects per request, and will operate in parallel: for a maximum of 5000 requests per 60 seconds, having at most 10 requests open at a time.

Usage

get_objects(
  object_ids,
  source,
  resource = get_default_resource(source),
  batch_size = 100
)

Arguments

object_ids

Vector of object_ids for a specific resource, these allow you to fetch a specific database record.

source

(Required) Character string indicating the source of the data to fetch. Currently supported data sources: rato will fetch RATO data and wfl will fetch data from the province of West Flanders.

resource

The resource to query. Defaults to the default resource for the given source.

batch_size

Number of objects to request per API call, default is 100. Setting this to a lower number will result in more API calls, but will also reduce the risk of timeouts or errors when requesting large datasets. When set to a higher number, the API may timeout or return an error if the dataset is too large.

Details

To query an ArcGIS REST API you need credentials. Without credentials accessing the raw data is not possible.

Value

tibble of requested objects.


Request an access token from the GIS API services

Description

The credentials are stored in your .Renviron file under RATO_USER and RATO_PWD and/or WFL_USER and WFL_PWD. To get credentials please contact the data sources directly.

Usage

get_token(source)

Arguments

source

(Required) Character string indicating the source of the data to fetch. Currently supported data sources: rato will fetch RATO data and wfl will fetch data from the province of West Flanders.

Details

By default tokens expire every 5 minutes, and are cached until they expire. You can set a different expiry duration by changing the ratatouille.token_expires_minutes option with options()

Value

Character. An access token for future API calls.


List all object ids for a resource on a ArcGIS Enterprise MapServer

Description

This function lists all object ids for a given resource on a ArcGIS Enterprise.

Usage

list_object_ids(source, resource = get_default_resource(source))

Arguments

source

(Required) Character string indicating the source of the data to fetch. Currently supported data sources: rato will fetch RATO data and wfl will fetch data from the province of West Flanders.

resource

The resource to query. Defaults to the default resource for the given source.

Value

Integer vector of (all) object ids.

Fetching all objects

Downloading all data for a resource consists of a two step process. First all object ids for a resource are queried. Then the objects are fetched from that resource by their id.

Caching

The returned id's are cached by default, but this can be overwritten by calling memoise::forget(list_object_ids) which will remove the cache and ensure the next call queries the database (but will reinstate the cache for any follow up calls).


Query object ids for a resource on a ArcGIS Enterprise MapServer

Description

This function returns all object ids that pass a query for a given resource on a ArcGIS Enterprise.

Usage

query_object_ids(
  source,
  resource = get_default_resource(source),
  query = "1=1"
)

Arguments

source

(Required) Character string indicating the source of the data to fetch. Currently supported data sources: rato will fetch RATO data and wfl will fetch data from the province of West Flanders.

resource

The resource to query. Defaults to the default resource for the given source.

query

A SQL where clause to filter the objects to query. Defaults to "1=1" which queries all objects, but can be used to filter the objects to query by any field in the table. For example, if you only want to query objects with a specific value in a field, you can use a query like "field_name = 'value'".

Value

Integer vector of (filtered) object ids.

Examples

query_object_ids("wfl",
  query = "Gemeente='Koekelare'"
)

Fetch raw invasive species data

Description

This function fetches the raw invasive species data from the specified source. It supports fetching data from RATO and other sources as they become available. All records from a source are returned, to fetch specific records see get_objects().

Usage

ratatouille(source, ...)

Arguments

source

(Required) Character string indicating the source of the data to fetch. Currently supported data sources: rato will fetch RATO data and wfl will fetch data from the province of West Flanders.

...

Arguments passed on to get_objects

batch_size

Number of objects to request per API call, default is 100. Setting this to a lower number will result in more API calls, but will also reduce the risk of timeouts or errors when requesting large datasets. When set to a higher number, the API may timeout or return an error if the dataset is too large.

Value

A data.frame containing the raw invasive species data from the selected source.

Examples

ratatouille(source = "rato")