Identifies the cell numbers of all cells within a ring defined by minimum
and maximum distances from focal cells.
Uses `spread`

under the hood, with specific values set.
Under many situations, this will be faster than using `rgeos::gBuffer`

twice (once for smaller ring and once for larger ring, then removing the
smaller ring cells).

1 2 3 4 5 6 7 8 | ```
rings(landscape, loci = NA_real_, id = FALSE, minRadius = 2,
maxRadius = 5, allowOverlap = FALSE, returnIndices = FALSE,
returnDistances = TRUE, ...)
## S4 method for signature 'RasterLayer'
rings(landscape, loci = NA_real_, id = FALSE,
minRadius = 2, maxRadius = 5, allowOverlap = FALSE,
returnIndices = FALSE, returnDistances = TRUE, ...)
``` |

`landscape` |
A |

`loci` |
A vector of locations in |

`id` |
Logical. If TRUE, returns a raster of events ids.
If FALSE, returns a raster of iteration numbers,
i.e., the spread history of one or more events. NOTE:
this is overridden if |

`minRadius` |
Numeric. Minimum radius to be included in the ring. Note: this is inclusive, i.e., >= |

`maxRadius` |
Numeric. Maximum radius to be included in the ring. Note: this is inclusive, i.e., <= |

`allowOverlap` |
Logical. If |

`returnIndices` |
Logical. Should the function return a data.table with indices and values of successful spread events, or return a raster with values. See Details. |

`returnDistances` |
Logical. Should the function inclue a column with the individual cell distances from the locus where that event started. Default is FALSE. See Details. |

`...` |
Any other argument passed to |

This will return a `data.table`

with columns
as described in `spread`

when `returnIndices = TRUE`

.

Eliot McIntire

`cir`

which uses a different algorithm.
`cir`

tends to be faster when there are few starting points, `rings`

tends to be faster when there are many starting points. Another difference
between the two functions is that `rings`

takes the centre of the pixel
as the centre of a circle, whereas `cir`

takes the exact coordinates.
See example.
`rgeos::gBuffer`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ```
library(raster)
# Make random forest cover map
emptyRas <- raster(extent(0,1e2,0,1e2), res = 1)
# start from two cells near middle
loci <- (ncell(emptyRas)/2 - ncol(emptyRas))/2 + c(-3, 3)
# Allow overlap
emptyRas[] <- 0
Rings <- rings(emptyRas, loci = loci, allowOverlap = TRUE, returnIndices = TRUE)
# Make a raster that adds together all id in a cell
wOverlap <- Rings[,list(sumEventID=sum(id)),by="indices"]
emptyRas[wOverlap$indices] <- wOverlap$sumEventID
if (interactive()) {
clearPlot()
Plot(emptyRas)
}
# No overlap is default, occurs randomly
emptyRas[] <- 0
Rings <- rings(emptyRas, loci = loci, minRadius = 7, maxRadius = 9, returnIndices = TRUE)
emptyRas[Rings$indices] <- Rings$id
if (interactive()) {
clearPlot()
Plot(emptyRas)
}
# Variable ring widths, including centre cell for smaller one
emptyRas[] <- 0
Rings <- rings(emptyRas, loci = loci, minRadius = c(0,7), maxRadius = c(8, 18),
returnIndices = TRUE)
emptyRas[Rings$indices] <- Rings$id
if (interactive()) {
clearPlot()
Plot(emptyRas)
}
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.