Skip to contents

Trip rasterize.

Usage

# S4 method for class 'trip,missing'
rasterize(x, grid = NULL, method = "pixellate", ...)

# S4 method for class 'trip,RasterLayer'
rasterize(x, y, field, fun = "pixellate", ...)

Arguments

x

trip object

y

Raster* object

field

attribute from which differences will be calculated, defaults to the time-stamp between trip locations

grid

grid to rasterize onto (GridTopology or Raster*), optional

method

rasterize method, "pixellate" (default) or "density"

fun

summary function applied to segment values

...

arguments passed to methods

Value

RasterLayer

Examples

 d <- data.frame(x=1:10, y=rnorm(10), tms=Sys.time() + 1:10, id=gl(2, 5))
tr <- trip(d, c("tms", "id"))
#> Warning: input looks like longitude/latitude data, assuming +proj=longlat +datum=WGS84

tr$temp <- sort(runif(nrow(tr)))
r <- rasterize(tr)

rasterize(tr, grid = r)
#> class      : RasterLayer 
#> dimensions : 100, 100, 10000  (nrow, ncol, ncell)
#> resolution : 0.09090909, 0.03850917  (x, y)
#> extent     : 0.9545455, 10.04545, -2.52555, 1.325367  (xmin, xmax, ymin, ymax)
#> crs        : NA 
#> source     : memory
#> names      : layer 
#> values     : 0, 0.09090909  (min, max)
#> 
# \donttest{
rasterize(tr, r, field = "temp")
#> class      : RasterLayer 
#> dimensions : 100, 100, 10000  (nrow, ncol, ncell)
#> resolution : 0.09090909, 0.03850917  (x, y)
#> extent     : 0.9545455, 10.04545, -2.52555, 1.325367  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> source     : memory
#> names      : layer 
#> values     : 0.003360847, 0.2877745  (min, max)
#> 
rasterize(tr, method = "density")
#> class      : RasterLayer 
#> dimensions : 100, 100, 10000  (nrow, ncol, ncell)
#> resolution : 0.09090909, 0.03850917  (x, y)
#> extent     : 0.9545455, 10.04545, -2.52555, 1.325367  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> source     : memory
#> names      : z 
#> values     : 0.01844323, 0.7884332  (min, max)
#> 
rasterize(tr, method = "density", grid = r)
#> class      : RasterLayer 
#> dimensions : 100, 100, 10000  (nrow, ncol, ncell)
#> resolution : 0.09090909, 0.03850917  (x, y)
#> extent     : 0.9545455, 10.04545, -2.52555, 1.325367  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> source     : memory
#> names      : z 
#> values     : 0.01844323, 0.7884332  (min, max)
#> 

rasterize(tr, r, field = "tms")
#> class      : RasterLayer 
#> dimensions : 100, 100, 10000  (nrow, ncol, ncell)
#> resolution : 0.09090909, 0.03850917  (x, y)
#> extent     : 0.9545455, 10.04545, -2.52555, 1.325367  (xmin, xmax, ymin, ymax)
#> crs        : +proj=longlat +datum=WGS84 +no_defs 
#> source     : memory
#> names      : layer 
#> values     : 1, 2  (min, max)
#> 
rasterize(tr, r)
#> class      : RasterLayer 
#> dimensions : 100, 100, 10000  (nrow, ncol, ncell)
#> resolution : 0.09090909, 0.03850917  (x, y)
#> extent     : 0.9545455, 10.04545, -2.52555, 1.325367  (xmin, xmax, ymin, ymax)
#> crs        : NA 
#> source     : memory
#> names      : layer 
#> values     : 0, 0.09090909  (min, max)
#> 

# }