Learn R Programming

geostatsp (version 0.7.0)

stackRasterList: Converts a list of rasters, possibly with different projections and resolutions, to a single raster stack.

Description

This function is intended to be used prior to passing covariates to krige in order for the rasters for all covariates to have the same projection and same resolution.

Usage

stackRasterList(x, template = x[[1]], method = "ngb")

Arguments

x
A list of rasters
template
A raster whose projection and resolution all other rasters will be aligned with. Defaults to the first raster in x
method
The method to use, either "ngb", or "bilinear". Can be a vector of the same length as x to specify different methods for each raster. If method has names which correspond to the names of x, the names will be used instead of th

Value

  • A raster stack.

Examples

Run this code
mylist = list(a=raster(matrix(1:9, 3, 3), 0,1,0,1, 
       crs="+proj=utm +zone=17 +ellps=GRS80 +units=m +no_defs"),
	b=raster(matrix(1:25, 5, 5), -1, 2, -1, 2,
	   crs="+proj=utm +zone=17 +ellps=GRS80 +units=m +no_defs")
	)
mystack = stackRasterList(mylist)
mystack



mylist = list(a=raster(matrix(1:9, 3, 3), 0,1000,0,1000, 
       crs="+proj=utm +zone=17 +ellps=GRS80 +units=m +no_defs"),
	b=raster(matrix(1:25, 5, 5), -85.49, -85.48, 0.003, 0.009,
	   crs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ")
	)
	
mystack = stackRasterList(mylist)
mystack

plot(mystack[["a"]], main="stack a")

Run the code above in your browser using DataLab