Learn R Programming

frheritage (version 0.1.0)

get_heritage_ids: Retrieve heritage layer IDs for a given sf object

Description

This function retrieves available layer identifiers from the French Ministry of Culture's "Atlas du Patrimoine" service feed, based on the spatial extent and department(s) of a given sf object.

Usage

get_heritage_ids(x, buffer = 2500, crs = 2154, verbose = TRUE)

Value

A data.frame with the following columns:

id

Numeric identifier extracted from the record GUID.

title

Record title as published in the service feed.

guid

Full GUID (unique resource identifier).

code

Internal code associated with the layer.

Returns an empty data.frame if no records are found or the request fails.

Arguments

x

An sf object defining the area of interest.

buffer

A numeric value (default = 2500). Buffer distance in meters used to slightly expand geometries before querying.

crs

An integer or sf::st_crs object (default = 2154). Coordinate reference system used for spatial processing.

verbose

Logical. If TRUE (default), prints progress and diagnostic messages.

Details

Internally, the function:

  1. Aggregates nearby geometries using buffer input.

  2. Determines the corresponding INSEE department code for each geometry, using happign::get_wfs().

  3. Computes the bounding box of each geometry.

  4. Queries the "Atlas du Patrimoine" service feed for all available metadata records (IDs, titles, GUIDs) within each bounding box.

Progress is shown for each request.

Examples

Run this code
# \donttest{
if (interactive()) {
  # Create a minimal sf object defining the area of interest.
  # A simple point geometry is sufficient to trigger spatial queries.
  my_sf_layer <- sf::st_sf(
    geometry = sf::st_sfc(
      sf::st_point(c(2.21, 48.82)),
      crs = 4326
    )
  )

  # Retrieve available heritage dataset identifiers intersecting
  # the spatial extent derived from the sf object.
  ids <- get_heritage_ids(my_sf_layer)
}
# }

Run the code above in your browser using DataLab