Package 'frheritage'

Title: R Interface to Get French Heritage Data
Description: Get spatial vector data from the Atlas du Patrimoine (<http://atlas.patrimoines.culture.fr/atlas/trunk/>), the official national platform of the French Ministry of Culture, and facilitate its use within R geospatial workflows. The package provides functions to list available heritage datasets, query and retrieve heritage data using spatial queries based on user-provided sf objects, perform spatial filtering operations, and return results as sf objects suitable for spatial analysis, mapping, and integration into heritage management and landscape studies.
Authors: Matthieu Chevereau [aut, cre]
Maintainer: Matthieu Chevereau <[email protected]>
License: GPL (>= 3)
Version: 0.1.1
Built: 2026-05-17 09:30:53 UTC
Source: https://github.com/mucau/frheritage

Help Index


Available layer datasets

Description

A dataset containing available layer datasets from the French Ministry of Culture's "Atlas du Patrimoine" service.

Usage

all_ids

Format

A data.frame with 5 columns:

id

(character) Layer id.

title

(character) Layer title.

guid

(integer) Layer guid.

code

(character) Internal code, determined from tile.

departement

(character) Layer department

Details

Contains only data available on the 96 departments of metropolitan France.


Retrieve INSEE department codes from an sf object

Description

This function retrieves the INSEE administrative department codes (code_insee) intersecting the features of a given sf object. It relies on the Admin Express COG WFS service provided by IGN, accessed via the happign package.

Usage

get_deps(x)

Arguments

x

An sf object defining the area(s) of interest.

Details

The function performs the following steps:

  1. Transforms the input geometries to CRS:4326.

  2. Computes centroids of the geometries.

  3. Queries the IGN WFS service (Admin Express COG) to retrieve departments.

  4. Performs a spatial join using sf::st_intersects().

  5. Extracts and returns unique code_insee values.

Notes:

  • The function depends on the availability of the IGN WFS service.

  • Large or complex geometries may cause the request to fail.

  • In such cases, consider simplifying or reducing the spatial extent of x.

Value

A character vector of unique INSEE department codes intersecting the input geometries. Returns NULL if no intersection is found or if the WFS request fails.

Examples

if (interactive()) {

  # Minimal sf object (point in Paris)
  x <- sf::st_sf(
    geometry = sf::st_sfc(
      sf::st_point(c(2.35, 48.85)),
      crs = 4326
    )
  )

  # Retrieve department code
  get_deps(x)

  # Multiple locations (Paris and Rouen)
  x2 <- sf::st_sf(
    geometry = sf::st_sfc(
      sf::st_point(c(2.35, 48.85)),  # 75
      sf::st_point(c(1.09, 49.44)),  # 76
      crs = 4326
    )
  )

  get_deps(x2)

}

Retrieve and download heritage spatial data for a given sf object

Description

This function retrieves and downloads spatial heritage datasets from the French Ministry of Culture’s "Atlas du Patrimoine" service.

Usage

get_heritage(x, data_code, buffer = 2500, crs = 2154, verbose = TRUE)

Arguments

x

An sf object defining the area of interest.

data_code

A single character heritage dataset codes to retrieve. Valid codes can be obtained with get_heritage_layernames().

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

It uses the spatial extent and inferred department(s) of the input sf object to query an internal registry of heritage datasets, then downloads and merges the corresponding spatial layers.

This function currently supports metropolitan France departments (96 units).

Internally, the function:

  1. Validates the input data_code against an internal registry.

  2. Prepares and optionally buffers the input geometry.

  3. Computes spatial extents (bounding boxes) for each feature.

  4. Assigns each feature to one or more administrative departments.

  5. Filters available heritage records using an internal dataset registry.

  6. Builds query URLs for the Atlas du Patrimoine service.

  7. Downloads ZIP archives containing shapefiles.

  8. Reads, validates, and merges the resulting sf objects.

Partial failures are tolerated: invalid or empty responses for individual requests are skipped.

Value

A single sf object containing all retrieved heritage features. Returns an empty sf object if no data is found or all requests fail.

Examples

if (interactive()) {

  # Define a minimal spatial object (WGS84 point)
  my_sf_layer <- sf::st_sf(
    geometry = sf::st_sfc(
      sf::st_point(c(2.21, 48.82)),
      crs = 4326
    )
  )

  # Retrieve heritage spatial data
  res <- get_heritage(
    x = my_sf_layer,
    data_code = "IMMH",
    buffer = 2000,
    crs = 2154,
    verbose = TRUE
  )

}

Retrieve heritage layer IDs for a given sf object

Description

This function retrieves available heritage dataset identifiers from the French Ministry of Culture’s "Atlas du Patrimoine" service.

Usage

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

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

It uses the spatial extent and inferred department(s) of the input sf object to query the service.

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.

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).

departement

Department code associated with the spatial query.

code

Internal code associated with the layer.

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

Examples

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)
}

Get heritage layer codes and labels

Description

This function provides a reference table mapping internal codes to explore heritage layer available datasets from French Ministry of Culture's "Atlas du Patrimoine". Optionally, it can filter the table to return only selected codes.

Usage

get_heritage_layernames(code = NULL)

Arguments

code

Optional character vector of layer codes to filter. If NULL, the full reference table is returned.

Details

The available codes and their meanings are:

  • IMDN — Domaines nationaux

  • IMMH — Immeubles classes ou inscrits

  • IMUN — Patrimoine Mondial UNESCO – Emprise surfacique des biens

  • LACR — Architecture Contemporaine Remarquable

  • PADN — Protection au titre des abords de domaines nationaux

  • PAMH — Protection au titre des abords de monuments historiques

  • PAUN — Patrimoine Mondial UNESCO – Zone tampon des biens

  • SICI — Sites classes ou inscrits

  • SIPR — Sites patrimoniaux remarquables

  • ZPPA — Zones de presomption de prescriptions archeologiques

Value

A data.frame with two columns:

code

Official heritage layer code (character).

label

Descriptive label (character).

Examples

# Get the full table of heritage layer codes
get_heritage_layernames()

# Filter for specific codes
get_heritage_layernames(c("IMMH", "SICI"))