1\name{replacement}
2
3\docType{methods}
4
5
6\alias{[<-,RasterLayer,RasterLayer,missing-method}
7\alias{[<-,RasterLayer,missing,missing-method}
8\alias{[<-,RasterStackBrick,Raster,missing-method}
9\alias{[<-,RasterStackBrick,missing,missing-method}
10
11\alias{[[<-,RasterStack,numeric,missing-method}
12\alias{[[<-,Raster,numeric,missing-method}
13\alias{[[<-,RasterStackBrick,character,missing-method}
14\alias{[[<-,RasterLayer,character,missing-method}
15
16\alias{[<-,Raster,numeric,numeric-method}
17\alias{[<-,Raster,numeric,missing-method}
18\alias{[<-,Raster,matrix,missing-method}
19\alias{[<-,Raster,logical,missing-method}
20\alias{[<-,Raster,missing,numeric-method}
21\alias{[<-,Raster,Spatial,missing-method}
22\alias{[<-,Raster,Extent,missing-method}
23\alias{[<-,Extent,numeric,missing-method}
24
25\alias{$<-,Raster-method}
26\alias{$,Raster-method}
27
28
29\title{Replace cell values or layers of a Raster* object}
30
31\description{
32You can set values of a Raster* object, when \code{i} is a vector of cell numbers, a Raster*, Extent, or Spatial* object.
33
34These are shorthand methods that work best for relatively small Raster* objects. In other cases you can use functions such as \code{\link{calc} and \link{rasterize}}.
35}
36
37\section{Methods}{
38\describe{
39\code{x[i] <- value}
40
41\code{x[i,j] <- value}
42
43\tabular{rll}{
44\tab \bold{Arguments:} \tab  \cr
45\tab \code{x} \tab a Raster* object \cr
46\tab \code{i} \tab cell number(s), row number(s), Extent, Spatial* object \cr
47\tab \code{j} \tab columns number(s) (only available if i is (are) a row number(s)) \cr
48\tab \code{value} \tab new cell value(s) \cr
49}
50}}
51
52\seealso{ \link{calc}, \link{rasterize}}
53
54
55\examples{
56r <- raster(ncol=10, nrow=5)
57values(r) <- 1:ncell(r) * 2
58r[1,] <- 1
59r[,1] <- 2
60r[1,1] <- 3
61
62s <- stack(r, sqrt(r))
63s[s<5] <- NA
64
65}
66
67\keyword{methods}
68\keyword{spatial}
69