Description Usage Arguments Details Value References See Also Examples
View source: R/modify.operators.R
The distance map of a binarised raster contains the distance of each background cell to the nearest foreground cell.
1 | rDistance(obj, method = "euclidean")
|
obj |
[ |
method |
[ |
In contrast to distance
, the distance
values here do not warp around the boundaries of the map.
A RasterLayer
of the same dimension as obj
, where the
value of the background cells has been replaced with the distance to the
nearest foreground cell.
Meijster, A., Roerdink, J.B.T.M., Hesselink, W.H., 2000. A general algorithm for computing distance transforms in linear time, in: Goutsias, J., Vincent, L., Bloomberg, D.S. (Eds.), Mathematical Morphology and Its Applications to Image and Signal Processing. Springer, pp. 331–340.
Other operators to modify cell values: rBinarise
,
rCategorise
, rFillNA
,
rOffset
, rPermute
,
rRange
, rSubstitute
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | input <- rtRasters$continuous
# the different distance metrics
binarised <- rBinarise(input, thresh = 40)
disEuc <- rDistance(binarised)
disMan <- rDistance(binarised, method = "manhattan")
disChb <- rDistance(binarised, method = "chessboard")
distances <- raster::stack(binarised, disEuc, disMan, disChb)
visualise(distances)
# calculate distance from edge to patch interior
inverted <- rPermute(binarised)
visualise(rDistance(inverted))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.