calc_dist_mat: Calculates the distance matrix (Raster)

Description Usage Arguments Details Value Examples

View source: R/calc_dist_mat.R

Description

Calculates the distance between all populated areas in a RasterLayer object.

Usage

1
calc_dist_mat(rasterl)

Arguments

raster_l

The RasterLayer object to use to calculate the distance matrix.

Details

This function calculates the distance matrix once to avoid doing it for every generation during an epidemic simulation. This is essential to later speed up the epidemic simulation. The matrix returned only contains distance between cells with non-NA values (i.e. cells with people in them). Note that this function assumes that the distances are in meters in the dataset! If that is not the case, you might want to either convert these, or adjust the output of this function.

Value

Returns one matrix object containg the distances between all populated areas.

Examples

1
2
3
4
5
#Create a RasterLayer object:
test_data = raster(nrow=10, ncol=10, xmn=1, xmx=100000, ymn=1, ymx=100000)
values(test_data) = runif(100, 1, 1000)

dist_mat = calc_dist_mat(test_data)

qleclerc/efficientspatial documentation built on May 23, 2019, 1:24 p.m.