wrap | R Documentation |
Generally for model development purposes.
wrap(obj, bounds, withHeading) ## S4 method for signature 'matrix,Extent,missing' wrap(obj, bounds) ## S4 method for signature 'SpatialPoints,ANY,missing' wrap(obj, bounds) ## S4 method for signature 'matrix,Raster,missing' wrap(obj, bounds) ## S4 method for signature 'matrix,Raster,missing' wrap(obj, bounds) ## S4 method for signature 'matrix,matrix,missing' wrap(obj, bounds) ## S4 method for signature 'SpatialPointsDataFrame,Extent,logical' wrap(obj, bounds, withHeading) ## S4 method for signature 'SpatialPointsDataFrame,Raster,logical' wrap(obj, bounds, withHeading) ## S4 method for signature 'SpatialPointsDataFrame,matrix,logical' wrap(obj, bounds, withHeading)
obj |
A |
bounds |
Either a |
withHeading |
Logical. If |
If withHeading
used, then obj must be a SpatialPointsDataFrame
that contains two columns, x1
and y1
, with the immediately previous
agent locations.
Same class as obj
, but with coordinates updated to reflect the wrapping.
Eliot McIntire
library(quickPlot) library(raster) xrange <- yrange <- c(-50, 50) hab <- raster(extent(c(xrange, yrange))) hab[] <- 0 # initialize agents N <- 10 # previous points x1 <- rep(0, N) y1 <- rep(0, N) # initial points starts <- cbind(x = stats::runif(N, xrange[1], xrange[2]), y = stats::runif(N, yrange[1], yrange[2])) # create the agent object agent <- SpatialPointsDataFrame(coords = starts, data = data.frame(x1, y1)) ln <- rlnorm(N, 1, 0.02) # log normal step length sd <- 30 # could be specified globally in params if (interactive()) { clearPlot() Plot(hab, zero.color = "white", axes = "L") } if (requireNamespace("SpaDES.tools")) { for (i in 1:10) { agent <- SpaDES.tools::crw(agent = agent, extent = extent(hab), stepLength = ln, stddev = sd, lonlat = FALSE, torus = TRUE) if (interactive()) Plot(agent, addTo = "hab", axes = TRUE) } }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.