Calculate the KNN distance between patches in a binary raster (or raster(s); a vector or list) specified by r=RasterLayer. You can either return the KNN index or some statistic (e.g., mean) specified by fun=. The default action is to return the full index. I have added multi-core support and use the gdal backend by default for this analysis. It's much faster than doing it in pure 'R'.
1 2 | calcPatchIsolation(r, fun = NULL, k = 1, method = "gdal",
from = "centroid", parallel = FALSE)
|
fun |
a function that is applied to all KNN distances (i.e., for calculating mean/median/mode distances). |
k |
the K (e.g., 1,2,3) value used for our K nearest-neighbor calculation. |
method |
string specifying whether 'gdal' or 'R' is used to vectorize our raster patches for the KNN calculation. |
from |
string specifying whether to calculate patch issolation distances from the 'edges' (i.e., minimum distance) or patch 'centroid'. default is 'edges'. |
parallel |
TRUE/FALSE specifying whether to parallelize our vectorization / KNN operations. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.