calc_dist_mat: Calculates the distance matrix

Description Usage Arguments Details Value Examples

Description

Calculates the distance between all populated areas in the spatial dataset.

Usage

1
calc_dist_mat(spatial_data)

Arguments

spatial_data

The spatial dataset 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 containing the distances between all populated areas.

Examples

1
2
3
4
5
#Create a spatial dataset:
test_data = raster::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/epicspatial documentation built on May 21, 2019, 4:06 a.m.