You need to sign in or sign up before continuing.
Handle network data with nodes outside the territory
mapMCDA
currently fails when a node falls outside the territory.
MRE:
library(mapMCDA)
library(sp)
cmr <- mapMCDA_datasets()
## Correct behaviour, when all nodes are within the territory
risk_layer(
cmr$mobility,
boundaries = cmr$cmr_admin3
)
#> class : RasterLayer
#> dimensions : 100, 67, 6700 (nrow, ncol, ncell)
#> resolution : 0.1142512, 0.1142512 (x, y)
#> extent : 8.499454, 16.15429, 1.652267, 13.07739 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
#> source : memory
#> names : layer
#> values : 0, 100 (min, max)
## Move one node outside of the national territory
cmr_nodes <- attr(cmr$mobility, "geom_node")
cmr_nodes[4] <- cmr_nodes[4] - 1
attr(cmr$mobility, "geom_node") <- cmr_nodes
plot(cmr$cmr_admin3, border = "darkgray")
plot(cmr$mobility, add = TRUE)
## Failure
risk_layer(
cmr$mobility,
boundaries = cmr$cmr_admin3
)
#> nerror = 16
#> Error in deldir::tile.list(z): Argument "object" is not of class "deldir".
Created on 2020-05-23 by the reprex package (v0.3.0)
Expected behaviour
mapMCDA
should automatically filter (with a warning) the part of the network within borders, and proceed from there.