Get Shared Borders Between EUs and Bordering Countries
calc_border_lengths.Rd
This function identifies shared borders between epidemiological units (EUs) and neighbouring countries. It accounts for small discrepancies in border alignments and adjusts accordingly using an algorithm that loops over all overlapping and divergent polygons.
This can take some time to run.
Distances are calculated using projection crs 6933 and uses s2. However, output remains WGS84.
Arguments
- epi_units
An
sf
object containing the epidemiological units dataset.- eu_country_iso3
A string specifying the iso3 code of the epidemiological units country.
NULL
by default, this argument is found by locatingepi_units
on a world map. Only required whenepi_units
does not correspond to an actual country.- neighbours
A string vector of iso3 codes corresponding to neighbouring countries of the
epi_units
.NULL
by default, neighbours are found using the riskintrodata::neighbours_table. If values are provide for this parameter, then any argument foreu_country_iso3
is not used.
Value
An sf
object containing shared borders between EUs and bordering countries,
with calculated border lengths and weights. The table is containing the following columns:
eu_id
: ID of the epidemiological unit.bc_id
: ISO3 of the bordering country.border_length
: Length of the shared border, use units::units to get the units. It is expected in km.geometry
: The geometry column containing the shared border, aMULTILINESTRING
orLINESTRING
.weight
: The risk weighting coefficient based on the length of the border.
Details
This is the first step in the border risk analysis method, the outputs of this
function should be passed on to calc_border_risk()
.
Examples
# \donttest{
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
tunisia_raw <- sf::read_sf(system.file(
package = "riskintrodata",
"samples", "tunisia", "epi_units", "tunisia_adm2_raw.gpkg"
))
# Apply mapping to prepare colnames and validate dataset
tunisia <- apply_mapping(
tunisia_raw,
mapping = mapping_epi_units(
eu_name = "NAME_2",
geometry = "geom"
),
validate = TRUE
)
#> ✔ All data in "epi_units" valided.
# Run function to get shared borders
shared_borders <- calc_border_lengths(
epi_units = tunisia
)
wahis_factors <- riskintrodata::get_wahis_erf(
disease = "Anthrax",
species = "Cattle",
animal_category = "Domestic"
)
#> ✔ All data in "emission_risk_factors" valided.
#> ✔ WAHIS emission risk factors dataset has 65 entries for `disease = Anthrax`, `species = Cattle`, and `animal_category = Domestic`.
emission_risk_table <- calc_emission_risk(wahis_factors)
ri_border <- calc_border_risk(
epi_units = tunisia,
shared_borders = shared_borders,
emission_risk = emission_risk_table
)
ri_border
#> Simple feature collection with 268 features and 4 fields
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: 7.530076 ymin: 30.23681 xmax: 11.59826 ymax: 37.55986
#> Geodetic CRS: WGS 84
#> # A tibble: 268 × 5
#> eu_id eu_name borders border_risk geometry
#> <chr> <chr> <dbl> <dbl> <GEOMETRY [°]>
#> 1 eu-00001 Ariana Médina NA 0 POLYGON ((10.13862 36.89432,…
#> 2 eu-00002 Ettadhamen NA 0 POLYGON ((10.05623 36.84281,…
#> 3 eu-00003 Kalaat El Andalous NA 0 MULTIPOLYGON (((10.13862 36.…
#> 4 eu-00004 Mnihla NA 0 POLYGON ((10.13109 36.88332,…
#> 5 eu-00005 Raoued NA 0 POLYGON ((10.17025 36.88844,…
#> 6 eu-00006 Sebkhet Ariana NA 0 POLYGON ((10.27149 36.88916,…
#> 7 eu-00007 Sidi Thabet NA 0 POLYGON ((10.00166 36.99815,…
#> 8 eu-00008 Soukra NA 0 POLYGON ((10.20232 36.85612,…
#> 9 eu-00009 Amdoun NA 0 POLYGON ((9.136977 36.87276,…
#> 10 eu-00010 Béja Nord NA 0 POLYGON ((9.091034 36.70194,…
#> # ℹ 258 more rows
border_lines <- extract_border(ri_border)
border_lines
#> Simple feature collection with 17 features and 9 fields
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: 7.530076 ymin: 30.23681 xmax: 11.59826 ymax: 36.91043
#> Geodetic CRS: WGS 84
#> # A tibble: 17 × 10
#> eu_id bc_id border_length geometry weight country
#> <chr> <chr> <dbl> <GEOMETRY [°]> <dbl> <chr>
#> 1 eu-00061 DZA 45.7 LINESTRING (8.130428 34.52643, 8… 1 NA
#> 2 eu-00065 DZA 51.1 MULTILINESTRING ((8.486515 36.69… 1 NA
#> 3 eu-00068 DZA 10.4 LINESTRING (8.448809 36.62249, 8… 1 NA
#> 4 eu-00069 DZA 73.6 MULTILINESTRING ((8.309212 36.43… 1 NA
#> 5 eu-00087 DZA 42.4 MULTILINESTRING ((8.272714 34.86… 1 NA
#> 6 eu-00088 DZA 48.9 MULTILINESTRING ((8.314248 35.31… 1 NA
#> 7 eu-00090 DZA 17.5 LINESTRING (8.388037 35.48045, 8… 1 NA
#> 8 eu-00094 DZA 13.5 LINESTRING (8.296709 34.74977, 8… 1 NA
#> 9 eu-00099 DZA 126. LINESTRING (8.354745 32.52821, 8… 1 NA
#> 10 eu-00107 DZA 44.2 LINESTRING (8.360878 35.63451, 8… 1 NA
#> 11 eu-00112 DZA 53.2 LINESTRING (8.291536 35.95223, 8… 1 NA
#> 12 eu-00133 LBY 130. LINESTRING (11.56026 33.15514, 1… 1 NA
#> 13 eu-00229 LBY 143. MULTILINESTRING ((10.61585 31.84… 1 NA
#> 14 eu-00231 DZA 293. LINESTRING (9.557298 30.23681, 9… 0.625 NA
#> 15 eu-00231 LBY 176. LINESTRING (10.13751 31.47516, 1… 0.375 NA
#> 16 eu-00236 DZA 85.0 LINESTRING (7.753589 33.42955, 7… 1 NA
#> 17 eu-00238 DZA 86.5 LINESTRING (7.587045 34.09025, 7… 1 NA
#> # ℹ 4 more variables: data_source <chr>, emission_risk <dbl>,
#> # border_risk <dbl>, border_label <list>
# }