getNetwork: Extract the necessary components for movement modelling form...

View source: R/movement.R

getNetworkR Documentation

Extract the necessary components for movement modelling form a population density raster.

Description

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.

Usage

getNetwork(raster, min = 1, matrix = TRUE)

Arguments

raster

A RasterLayer object of population density.

min

The minimum population size for inclusion in the network. All cells with populations greater than or equal to min will be included and other excluded.

matrix

Whether the distance matrix should be returned as a matrix object (if TRUE) or as a dist object (if FALSE).

Value

A list with four components:

population

A vector giving the populations at the cells of interest

distance_matrix

A distance matrix (either of class matrix or dist) diving the pairwise euclidean distance between the cells of interest in the units of raster

coordinate

A two-column matrix giving the coordinates of the cells of interest in the units of raster

locations

A vector giving the locations at the cells of interest

See Also

raster, dist

Examples

# 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))

SEEG-Oxford/movement documentation built on April 17, 2023, 4:17 p.m.