Computes the spherical distance (in kilometers) from each PRIO-GRID cell centroid to the nearest international border using CShapes 2.0 boundary data. The function calculates distances to shared borders between countries, regardless of whether countries are separated by international waters.
Usage
bdist2(measurement_date, cshp = read_cshapes(), past_result = NULL)Arguments
- measurement_date
A single
Dateobject specifying the date for boundary analysis. Must be within CShapes temporal coverage.- cshp
An
sfobject containing CShapes 2.0 boundary data. Defaults toread_cshapes()if not provided.- past_result
A list object from a previous
bdist2calculation. If boundaries haven't changed, the function returns this result directly, avoiding recomputation. Default is NULL.
Value
A list containing three elements:
bdist2: ASpatRasterwith distances (km) from cell centroids to nearest international borders, masked to state system coverageboundaries: Ansfobject with country boundary line geometriesshared_borders: Ansfobject with shared border segments between neighboring countries
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 <- bdist2(as.Date("2010-01-01"))
} # }