as.logical-methods: Change cell values to logical or integer values

Description Usage Arguments See Also Examples

Description

Change values of a Raster* object to logical or integer values. With as.logical, zero becomes FALSE, all other values become TRUE. With as.integer values are truncated.

Usage

1
2
3
4
5
## S4 method for signature 'Raster'
as.logical(x, filename='', ...)

## S4 method for signature 'Raster'
as.integer(x, filename='', ...)

Arguments

x

Raster* object

filename

character. Output filename (optional)

...

additional optional arguments as for writeRaster

See Also

as.logical, as.integer

Examples

1
2
3
4
5
6
7
r <- raster(nrow=10, ncol=10)
set.seed(0)
r[] <- runif(ncell(r)) * 10
r
r <- as.integer(r)
r
as.logical(r)

Example output

Loading required package: sp
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
class       : RasterLayer 
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 36, 18  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : in memory
names       : layer 
values      : 0.1339033, 9.919061  (min, max)

NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
class       : RasterLayer 
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 36, 18  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : in memory
names       : layer 
values      : 0, 9  (min, max)

NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
class       : RasterLayer 
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 36, 18  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : in memory
names       : layer 
values      : 0, 1  (min, max)

raster documentation built on Nov. 17, 2017, 5:51 a.m.