File: cover.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 (62 lines) | stat: -rw-r--r-- 1,844 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
\name{cover}

\docType{methods}

\alias{cover}
\alias{cover,RasterLayer,RasterLayer-method}
\alias{cover,RasterStackBrick,Raster-method}
\alias{cover,SpatialPolygons,SpatialPolygons-method}


\title{ Replace NA values with values of other layers }

\description{
For Raster* objects: Replace \code{NA} values in the first Raster object (\code{x}) with the values of the second (\code{y}), and so forth for additional Rasters. If \code{x} has multiple layers, the subsequent Raster objects should have the same number of layers, or have a single layer only (which will be recycled).

For SpatialPolygons* objects: Areas of \code{x} that overlap with \code{y} are replaced by (or intersected with) \code{y}.
}

\usage{
\S4method{cover}{RasterLayer,RasterLayer}(x, y, ..., filename='')

\S4method{cover}{RasterStackBrick,Raster}(x, y, ..., filename='')

\S4method{cover}{SpatialPolygons,SpatialPolygons}(x, y, ..., identity=FALSE)
}

\arguments{
  \item{x}{Raster* or SpatialPolygons* object}
  \item{y}{Same as \code{x}}
  \item{filename}{character. Output filename (optional)}
  \item{...}{Same as \code{x}. If \code{x} is a Raster* object, also additional arguments as for \code{\link{writeRaster}}} 
  \item{identity}{logical. If \code{TRUE} overlapping areas are intersected rather than replaced}
}


\value{
RasterLayer or RasterBrick object, or SpatialPolygons object
}

\examples{
# raster objects
r1 <- raster(ncols=36, nrows=18)
values(r1) <- 1:ncell(r1)
r2 <- setValues(r1, runif(ncell(r1)))
r2[r2 < 0.5] <- NA
r3 <- cover(r2, r1)


#SpatialPolygons
p <- shapefile(system.file("external/lux.shp", package="raster"))
b <- as(extent(6, 6.4, 49.75, 50), 'SpatialPolygons')
crs(b) <- crs(p)
b <- SpatialPolygonsDataFrame(b, data.frame(ID_1=9))
	
cv1 <- cover(p, b)
cv2 <- cover(p, b, identity=TRUE)

}


\keyword{methods}
\keyword{spatial}