Description Usage Arguments Value
This returns the (sparse) Matrix giving the pseudo-adjacency matrix from and to for specified cells in the given Raster, with weights.
1 2 3 4 5 |
population |
Population object or Raster*. |
accessible |
Logical vector indicating which cells in 'habitat' that migrants will attempt to go to. |
migration |
Migration object; is overridden by other parameters below. |
kern |
Weighting kernel applied to distances. |
sigma |
Distance scaling for kernel. |
radius |
Maximum distance away to truncate the kernel. |
normalize |
If not NULL, migration weights to accessible locations are set to sum to this (see details). |
from |
The indices of the cells corresponding to rows in the output matrix. [default: non-NA cells] |
to |
The indices of the cells corresponding to columns in the output matrix. [default: same as |
discretize |
Whether or not to "discretize" the kernel first using the |
disc.fact |
The discretization factor, if used (see |
n.chunks |
Number of chunks to compute the matrix in (can help with memory usage). |
A sparse Matrix M
, where for each pair of cells i
in from
and i
in to
,
the value M[i,j]
is
kern( d[i,j]/sigma )
or, if kern="gaussian"
,
exp( - d[i,j]^2/sigma^2 ) / ( 2 pi sigma^2 ) * (area of a cell)
where d[i,j]
is the distance from from[i]
to to[j]
,
if this is greater than min.prob
, and is 0 otherwise.
Summary of how to encode different types of boundary: set absorbing boundary elements to accessible, but do not include them in from (and to). Mark reflecting (non-)boundaries as not accessible. External boundaries will be reflecting, so if they should be absorbing, you need to extend the raster and set values appropriately.
Migration is possible to each accessible
cell in the Raster*.
If normalize
is not NULL, then for each cell, the set of migration weights to each other accessible cell
within distance radius
is normalized to sum to normalize
.
The resulting matrix may not have rows summing to normalize
,
however, if from
is a subset of the accessible
ones.
If not normalized, the kernel is multiplied by the area of the cell (taken to be approximately constant).
The usual way to use this is to call migration_matrix(pop,mig)
,
where pop
is a population
object, which contains both the Raster
and the vector of which locations are accessible;
and mig
is a migration
object containing the kernel, migration radius, etcetera.
Alternatively, population
can be a RasterLayer,
in which case by default all non-NA cells are accessible.
Inaccessible cells included in to
,
have zero migration outwards.
Inaccessible cells included in from
behave as usual.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.