File: replacement.Rd

package info (click to toggle)
r-cran-raster 3.6-31-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,300 kB
  • sloc: cpp: 2,367; ansic: 1,572; sh: 13; makefile: 2
file content (68 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
\name{replacement}

\docType{methods}


\alias{[<-,RasterLayer,RasterLayer,missing-method}
\alias{[<-,RasterLayer,missing,missing-method}
\alias{[<-,RasterStackBrick,Raster,missing-method}
\alias{[<-,RasterStackBrick,missing,missing-method}

\alias{[[<-,RasterStack,numeric,missing-method}
\alias{[[<-,Raster,numeric,missing-method}
\alias{[[<-,RasterStackBrick,character,missing-method}
\alias{[[<-,RasterLayer,character,missing-method}

\alias{[<-,Raster,numeric,numeric-method}
\alias{[<-,Raster,numeric,missing-method}
\alias{[<-,Raster,matrix,missing-method}
\alias{[<-,Raster,logical,missing-method}
\alias{[<-,Raster,missing,numeric-method}
\alias{[<-,Raster,Spatial,missing-method}
\alias{[<-,Raster,Extent,missing-method}
\alias{[<-,Extent,numeric,missing-method}

\alias{$<-,Raster-method}
\alias{$,Raster-method}


\title{Replace cell values or layers of a Raster* object}

\description{
You can set values of a Raster* object, when \code{i} is a vector of cell numbers, a Raster*, Extent, or Spatial* object. 

These 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}}. 
}

\section{Methods}{
\describe{
\code{x[i] <- value}

\code{x[i,j] <- value}

\tabular{rll}{
\tab \bold{Arguments:} \tab  \cr
\tab \code{x} \tab a Raster* object \cr
\tab \code{i} \tab cell number(s), row number(s), Extent, Spatial* object \cr
\tab \code{j} \tab columns number(s) (only available if i is (are) a row number(s)) \cr
\tab \code{value} \tab new cell value(s) \cr
}
}}

\seealso{ \link{calc}, \link{rasterize}} 


\examples{
r <- raster(ncol=10, nrow=5)
values(r) <- 1:ncell(r) * 2
r[1,] <- 1
r[,1] <- 2
r[1,1] <- 3

s <- stack(r, sqrt(r))
s[s<5] <- NA

}

\keyword{methods}
\keyword{spatial}