Skip to contents

Computes the spherical distance (in kilometers) from each PRIO-GRID cell centroid to the territorial outline of the country the cell belongs to using CShapes 2.0 boundary data.

Usage

bdist3(measurement_date, cshp = read_cshapes(), past_result = NULL)

Arguments

measurement_date

A single Date object specifying the date for boundary analysis. Must be within CShapes temporal coverage.

cshp

An sf object containing CShapes 2.0 boundary data. Defaults to read_cshapes() if not provided.

past_result

A list object from a previous bdist3 calculation. If boundaries haven't changed, the function returns this result directly, avoiding recomputation. Default is NULL.

Value

A list containing three elements:

  • bdist3: A SpatRaster with distances (km) from cell centroids to the border of the country.

  • boundaries: An sf object with country boundary line geometries

Details

The function includes optimization logic that reuses previous calculations if country boundaries haven't changed since the last computation, significantly reducing processing time for temporal sequences.

Distance calculations use spherical geometry (S2) for accurate measurements across the globe, particularly important for high-latitude regions.

References

Schvitz G, Girardin L, Rüegger S, Weidmann NB, Cederman L, Gleditsch KS (2022). “Mapping the International System, 1886-2019: The CShapes 2.0 Dataset.” Journal of Conflict Resolution, 66(1), 144–161. ISSN 0022-0027, doi:10.1177/00220027211013563 , 2024-11-22.

Examples

if (FALSE) { # \dontrun{
# Calculate border distances for 2010
border_dist_2010 <- bdist3(as.Date("2010-01-01"))
} # }