Cirad-ASTRE / mapMCDA

Produce an epidemiological risk map by weighting multiple risk factors
https://umr-astre.pages.mia.inra.fr/mapMCDA/
1 stars 2 forks source link

Rasterisation of networks with R0 = 0 #16

Closed famuvie closed 5 years ago

famuvie commented 5 years ago

For animal mobility networks where every node is either a source or a destination (but not both), the $R_0$ of the network is exactly 0. Thus, the contribution of every node is also 0. The code divides the individual contributions by the total $R_0 = 0$ to compute the relative contributions and returns NA.

library(mapMCDA)
edg <- data.frame(O = "A", D = "B")
nds <- data.frame(
  node = LETTERS[1:2],
  x = 1:2,
  y = 1:2
)
gn <- geonetwork::geonetwork(edg, nds)

r <- raster::raster(
  nrow = 10, ncol = 10, xmn = 0, xmx = 10, ymn = 0, ymx = 10, vals = 1
)

rasterize(gn, r)
#> class       : RasterLayer 
#> dimensions  : 10, 10, 100  (nrow, ncol, ncell)
#> resolution  : 1, 1  (x, y)
#> extent      : 0, 10, 0, 10  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       : layer 
#> values      : NA, NA  (min, max)

Created on 2019-04-07 by the reprex package (v0.2.0).

Expected output: a constant value equal to 100/N, where N is the number of nodes.