getNetwork | R Documentation |
Given raster map of population density, extract a distance matrix and vector of population sizes for all cells with population density above a minimum threshold. These can be used as network representation of the landscape for use in movement models.
getNetwork(raster, min = 1, matrix = TRUE)
raster |
A |
min |
The minimum population size for inclusion in the network. All
cells with populations greater than or equal to |
matrix |
Whether the distance matrix should be returned as a
|
A list with four components:
population |
A vector giving the populations at the cells of interest |
distance_matrix |
A distance matrix (either of class |
coordinate |
A two-column matrix giving the coordinates of the cells
of interest in the units of |
locations |
A vector giving the locations at the cells of interest |
raster
, dist
# load kenya raster
data(kenya)
# aggregate to 10km to speed things up
kenya10 <- raster::aggregate(kenya, 10, sum)
# get the network for pixels with at least 50,000 inhabitants
net <- getNetwork(kenya10, min = 50000)
# visualise the distance matrix
sp::plot(raster::raster(net$distance_matrix))
# plot the raster layer
sp::plot(kenya10)
# rescale the population of those pixels for plotting
size <- 0.1 + 2 * net$population / max(net$population)
# plot the pixels selected, with point size proportional to population size
points(net$coordinates, pch = 16,
cex = size,
col = rgb(0, 0, 1, 0.6))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.