| Pimage | R Documentation |
Create object to store binned images.
Pimage(x, ...)
## S3 method for class 'POSIXct'
Pimage(
x,
type = c("primary", "intermediate"),
pimg = NULL,
grid = NULL,
proj = NULL,
...
)
## Default S3 method:
Pimage(
x,
type = c("primary", "intermediate"),
pimg = NULL,
grid = NULL,
proj = NULL,
...
)
x |
vector of POSIXct date-times for locations |
... |
arguments passed to |
type |
character, samples to bin, "primary" or "intermediate" |
pimg |
a Pimage object to accept these samples, if not supplied one will be created base on the inputs |
grid |
object to use as a template for grid specification,
can be a anything accepted by |
proj |
a character string of projection arguments, see Details |
These functions provide a data structure tools to store binned samples generated by the Metropolis samplers.
These functions provide spatial binning of samples. A spatial summary image is stored separately for each time step and may be mosaiced into the entire study region. Separate summaries may be combined to create a multiple-track summary.
If pimg is supplied grid and proj are ignored
and binning is added to the existing pimg. If pimg
or is not supplied grid is used to build one with the
details from the fit object, and proj is ignored. If only
proj is supplied a grid is build using that projection and
the details from the fit object.
The proj argument should be a PROJ.4 string, see
projection and CRS, or an
incomplete PROJ.4 name string. If the string consists only of the
projection family name then a central coordinate is calculated
from the samples.See rgdal::projInfo("proj")$name for
candidate strings, and http://www.spatialreference.org for
more details.
Pimage
## Not run:
## Brownian motion tethered at each end
brownian.bridge <- function(n, r) {
x <- cumsum(rnorm(n, 0, 1))
x <- x - (x[1] + seq(0, 1, length=n) * (x[n] - x[1]))
r * x
}
## Number of days and number of obs
days <- 50
n <- 200
x <- rgamma(n, 3)
x <- cumsum(x)
x <- x/x[n]
b.scale <- 0.6
r.scale <- sample(c(0.1, 2, 10.2), n, replace=TRUE,
prob=c(0.8, 0.18, 0.02))
set.seed(71)
tms <- ISOdate(2001, 1, 1) + trunc(days * 24 * 60 * 60 *x)
lon <- 120 + 20 * sin(2 * pi * x) +
brownian.bridge(n, b.scale) + rnorm(n, 0, r.scale)
lat <- -40 + 10 *(sin(3 * 2 * pi * x) + cos(2 * pi * x) - 1) +
brownian.bridge(n, b.scale) + rnorm(n, 0, r.scale)
x0 <- cbind(lon, lat)
z0 <- trackMidpts(x0)
n3 <- 1500
fx <- list(x = list(array(NA_real_, c(length(lon), 2L, n3))),
z = list(array(NA_real_, c(length(lon)-1L, 2L, n3))),
model = list(time = tms))
fx$x[[1L]][,,1L] <- x0
fx$z[[1L]][,,1L] <- z0
for (i in seq(n3)[-1L]) {
fx$x[[1L]][,,i] <- jitter(x0, factor = 8L)
fx$z[[1L]][,,i] <- jitter(z0, factor = 12L)
}
g <- raster(extent(x0) + 5, nrows = 350, ncols = 375, crs = "+proj=longlat +datum=WGS84")
px <- Pimage(fx, grid = g)
pz <- Pimage(fx, type = "intermediate", grid = g)
for (i in seq(n3)[-1L]) {
fx$x[[1L]][,,i] <- jitter(x0, factor = 8L)
fx$z[[1L]][,,i] <- jitter(z0, factor = 12L)
}
px2 <- Pimage(fx, pimg = px)
pz2 <- Pimage(fx, type = "intermediate", pimg = pz)
px3 <- Pimage(fx, grid = g)
pz3 <- Pimage(fx, grid = g, type = "intermediate")
## first
px$p[[80]]
## this should be the sum of first and last
px2$p[[80]]
## last
px3$p[[80]]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.