Package 'alboFr'

Title: Get French Data on Tiger Mosquito Colonisation
Description: Get French Data on Tiger Mosquito (Aedes Albopictus) colonisation in France from the online map at <https://signalement-moustique.anses.fr/signalement_albopictus/colonisees>.
Authors: Egor Kotov [aut, cre] (ORCID: <https://orcid.org/0000-0001-6690-5345>)
Maintainer: Egor Kotov <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2026-09-26 09:55:29 UTC
Source: https://github.com/e-kotov/alboFr

Help Index


Fetch raw HTML page from the ANSES tiger mosquito colonisation map

Description

Downloads the HTML source code from the official ANSES tiger mosquito map with configurable connection timeout, automatic retries with exponential backoff and jitter, and a descriptive User-Agent header.

Usage

fetch_tiger_mosquito_page(
  url = source_url_tiger_mosquito,
  timeout = 60,
  max_retries = 3,
  retry_delay = 5,
  user_agent = NULL,
  sleep_func = Sys.sleep
)

Arguments

url

The URL of the webpage to fetch. Defaults to the official ANSES tiger mosquito colonisation page.

timeout

Connection timeout in seconds. Default is 60.

max_retries

Maximum number of fetch attempts. Default is 3.

retry_delay

Base delay in seconds between retries (uses exponential backoff with jitter). Default is 5.

user_agent

Custom User-Agent header string. Defaults to ⁠alboFr/<version> (R <version>; <platform>)⁠.

sleep_func

Internal function used for delays during backoff. Defaults to Sys.sleep.

Value

A single character string containing the raw HTML content encoded in UTF-8.

Examples

## Not run: 
# Fetch page with custom timeout and retries
page_html <- fetch_tiger_mosquito_page(timeout = 30, max_retries = 2)

# Reuse fetched page across data and metadata extraction
data <- get_tiger_mosquito_colonisation_in_france(page = page_html, output = "geojson")
meta <- get_tiger_mosquito_colonisation_metadata(page = page_html)

## End(Not run)

Get latest tiger mosquito colonisation data in France from the online map

Description

Get latest tiger mosquito colonisation data in France from the online map at https://signalement-moustique.anses.fr/signalement_albopictus/colonisees.

Usage

get_tiger_mosquito_colonisation_in_france(
  output = c("sf", "geojson"),
  page = NULL,
  timeout = 60,
  max_retries = 3,
  retry_delay = 5,
  user_agent = NULL
)

Arguments

output

The output format. Can be either "sf" or "geojson".

page

Optional pre-fetched HTML page source code (as a character vector of lines or a single string). If NULL (the default), the page will be downloaded automatically.

timeout

Connection timeout in seconds when downloading the page. Default is 60.

max_retries

Maximum number of download attempts. Default is 3.

retry_delay

Base delay in seconds between retries (exponential backoff with jitter). Default is 5.

user_agent

Custom User-Agent header string. Defaults to ⁠alboFr/<version> (R <version>; <platform>)⁠.

Value

If output = "sf", an sf object with the tiger mosquito colonisation data in France. All polygons that exist on the map are covering the territories where the tiger mosquito (Aedes Albopictus) has alreadt been detected in France. If output = "geojson", a GeoJSON in a character vector with the tiger mosquito colonisation data in France. Using the 'geojson' option allows to use the package without the sf package. You can therefore just save the resulting string to a text file. See examples.

Examples

## Not run: 
# get the latest data in `sf`
x <- get_tiger_mosquito_colonisation_in_france(output = "sf")

# save the data to GeoPackage file with `sf`
if (interactive()) {
  library(sf)
  st_write(x, "tiger_mosquito_colonisation_in_france.gpkg")
}

# fetch once and reuse page for both data and metadata
page_html <- fetch_tiger_mosquito_page()
x_sf <- get_tiger_mosquito_colonisation_in_france(output = "sf", page = page_html)
x_meta <- get_tiger_mosquito_colonisation_metadata(page = page_html)

# get the latest data in `geojson`
x <- get_tiger_mosquito_colonisation_in_france(output = "geojson")

# save the data to text file
if (interactive()) {
  writeLines(x, "tiger_mosquito_colonisation_in_france.geojson")
}

## End(Not run)

Get source metadata for tiger mosquito colonisation data

Description

Fetch metadata from the ANSES online map page, including the official update date displayed on the page when it can be parsed.

Usage

get_tiger_mosquito_colonisation_metadata(
  page = NULL,
  timeout = 60,
  max_retries = 3,
  retry_delay = 5,
  user_agent = NULL
)

Arguments

page

Optional pre-fetched HTML page source code (as a character vector of lines or a single string). If NULL (the default), the page will be downloaded automatically.

timeout

Connection timeout in seconds when downloading the page. Default is 60.

max_retries

Maximum number of download attempts. Default is 3.

retry_delay

Base delay in seconds between retries (exponential backoff with jitter). Default is 5.

user_agent

Custom User-Agent header string. Defaults to ⁠alboFr/<version> (R <version>; <platform>)⁠.

Value

A named list with source_url, source_official_update_date, and fetched_at.

Examples

## Not run: 
# Fetch metadata directly
meta <- get_tiger_mosquito_colonisation_metadata()

# Reuse a pre-fetched page
page_html <- fetch_tiger_mosquito_page()
meta <- get_tiger_mosquito_colonisation_metadata(page = page_html)

## End(Not run)

Compute a canonical dataset hash for tiger mosquito GeoJSON data

Description

Compute a SHA-256 hash for the set of GeoJSON features. The hash is stable to feature order, whitespace, and JSON formatting changes.

Usage

get_tiger_mosquito_dataset_hash(x)

Arguments

x

A GeoJSON string or path to a GeoJSON file.

Details

Individual feature SHA-256 hashes are computed (using 15-digit coordinate precision and radix-sorted properties) and then sorted in byte-wise order using sort(..., method = "radix"). A SHA-256 digest is then computed over the resulting canonical FeatureCollection structure.

Value

A SHA-256 hash as a character vector of length 1.


Compute canonical feature hashes for tiger mosquito GeoJSON data

Description

Compute one SHA-256 hash per GeoJSON feature after normalising JSON object ordering and excluding archive-added fields.

Usage

get_tiger_mosquito_feature_hashes(x)

Arguments

x

A GeoJSON string or path to a GeoJSON file.

Details

Canonical feature hashing follows these normalization rules:

  • Radix key ordering: Object keys are sorted using order(..., method = "radix") to ensure byte-wise (C-locale) deterministic ordering regardless of session LC_COLLATE settings.

  • 15-digit coordinate precision: Geometry coordinates are serialized with digits = 15, preserving IEEE-754 double precision for stable coordinate representation across platforms while absorbing minor floating-point printing artifacts across snapshots.

  • Excluded metadata: Archive-added and metadata attributes (feature_hash, source_url, source_official_update_date, fetched_at, data_canonical_sha256, and previous_data_canonical_sha256) are removed prior to hashing.

Value

A character vector of SHA-256 hashes, one per feature.