File: Compare-methods.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 (55 lines) | stat: -rw-r--r-- 1,575 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
\name{Compare-methods}

\docType{methods}

\alias{Compare-methods}

\alias{Compare,Extent,Extent-method}
\alias{Compare,Raster,Raster-method}
\alias{Compare,Raster,logical-method}
\alias{Compare,Raster,numeric-method}
\alias{Compare,logical,Raster-method}
\alias{Compare,numeric,Raster-method}

\alias{==,BasicRaster,BasicRaster-method}
\alias{!=,BasicRaster,BasicRaster-method}

\title{Compare Raster* objects}
\description{
These methods compare the location and resolution of Raster* objects. That is, they compare their spatial extent, projection, and number of rows and columns. 
 
For \code{BasicRaster} objects you can use \code{==} and \code{!=}, the values returned is a single logical value \code{TRUE} or \code{FALSE}
 
For RasterLayer objects, these operators also compare the values associated with the objects, and the result is a RasterLayer object with logical (Boolean) values. 
 
The following methods have been implemented for RasterLayer objects:
 
 \code{==, !=, >, <,  <=, >=}
}


\value{
A logical value or a RasterLayer object, and in some cases the side effect of a new file on disk.
}




\examples{
r1 <- raster()
r1 <- setValues(r1, round(10 * runif(ncell(r1))))
r2 <- setValues(r1, round(10 * runif(ncell(r1))))
as(r1, 'BasicRaster') == as(r2, 'BasicRaster')
r3 <- r1 == r2

b <- extent(0, 360, 0, 180)
r4 <- setExtent(r2, b)
as(r2, 'BasicRaster') != as(r4, 'BasicRaster')
# The following would give an error. You cannot compare RasterLayer 
# that do not have the same BasicRaster properties.
#r3 <- r1 > r4
}


\keyword{methods}
\keyword{math}