Learn R Programming

frheritage (version 0.1.0)

geo_dep: Retrieve INSEE department codes for each feature in an sf object

Description

This internal helper retrieves the administrative department (code_insee) intersecting each feature of the input sf object. It uses the Admin Express COG WFS service from IGN via the happign package.

Usage

geo_dep(x)

Value

A character vector with the INSEE department code corresponding to each feature of x. Returns NULL if no intersection is found.

Arguments

x

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

Details

  • The input is first transform to CRS:4326.

  • Centroids of the features are computed before querying the WFS service.

  • The function uses quiet() to suppress warnings/messages during processing.

  • If the WFS query fails or returns no features, a vector of NA values is returned.

  • The spatial join is performed using sf::st_join() with st_intersects.