Package ‘raster’
June 2, 2016
Type Package
Title Geographic Data Analysis and Modeling
Version 2.5-8
Date 2016-05-31
Depends methods, sp (>= 1.2-0), R (>= 3.0.0)
Suggests rgdal (>= 0.9-1), rgeos (>= 0.3-8), ncdf4, igraph, tcltk,
parallel, rasterVis
LinkingTo Rcpp
Imports Rcpp
Description
Reading, writing, manipulating, analyzing and modeling of gridded spatial data. The pack-
age implements basic and high-level functions. Processing of very large files is supported.
License GPL (>= 3)
URL http://cran.r-project.org/package=raster
ByteCompile TRUE
NeedsCompilation yes
Author Robert J. Hijmans [cre, aut],
Jacob van Etten [ctb],
Joe Cheng [ctb],
Matteo Mattiuzzi [ctb],
Michael Sumner [ctb],
Jonathan A. Greenberg [ctb],
Oscar Perpinan Lamigueiro [ctb],
Andrew Bevan [ctb],
Etienne B. Racine [ctb],
Ashton Shortridge [ctb]
Maintainer Robert J. Hijmans
Repository CRAN
Date/Publication 2016-06-02 18:31:24
1
2
R topics documented:
R topics documented:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
raster-package .
.
.
.
.
addLayer
.
.
.
adjacent
.
.
.
.
aggregate .
.
.
alignExtent
.
.
.
.
animate .
.
.
.
.
approxNA .
.
.
area .
.
.
.
.
Arith-methods .
.
.
as.data.frame .
.
.
.
as.list
.
.
.
.
as.logical
.
.
as.matrix .
.
.
.
.
as.raster .
.
atan2 .
.
.
.
.
autocorrelation .
.
.
.
bands
.
.
.
barplot .
.
.
.
bind .
.
.
.
.
blockSize .
.
.
boundaries .
.
.
boxplot
.
.
.
.
.
.
brick .
.
.
.
.
buffer
.
.
calc .
.
.
.
cellFrom .
.
.
.
cellsFromExtent .
.
.
cellStats .
.
.
clamp .
.
.
clearValues
.
.
.
.
.
click .
.
.
.
.
.
clump .
.
.
cluster .
.
.
.
colortable .
.
.
Compare-methods .
.
compareCRS .
.
compareRaster
.
.
contour
.
.
.
.
.
corLocal .
.
.
.
.
cover .
.
.
.
crop .
.
.
crosstab .
.
.
.
.
.
.
cut .
.
.
cv .
.
.
.
.
datasource .
dataType .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
R topics documented:
3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
density .
.
.
dim .
.
.
.
.
direction .
.
disaggregate .
distance .
.
.
distanceFromPoints .
.
.
.
.
draw .
.
.
.
.
.
drawExtent
.
.
.
.
.
.
erase .
.
.
.
.
.
extend .
.
.
.
.
.
extension .
.
.
.
.
extent
.
.
.
.
.
Extent math .
.
.
.
Extent-class .
.
.
extract .
.
.
Extract by index .
.
.
Extreme coordinates
.
.
extremeValues .
.
.
.
factors .
.
.
.
filename .
.
.
.
.
.
.
filledContour
.
.
.
.
.
flip .
.
.
.
.
.
flowPath .
.
.
.
focal .
.
.
.
.
.
.
.
.
focalWeight
.
.
freq .
.
.
.
.
.
Gain and offset
.
geom .
.
.
.
.
.
.
getData .
.
getValues
.
.
.
getValuesBlock .
getValuesFocal
.
.
.
.
gridDistance .
.
.
.
.
.
hdr .
.
.
.
.
.
head .
.
.
hillShade
.
.
.
.
.
.
.
.
hist .
.
.
.
.
.
.
image .
.
.
.
.
inifile .
.
.
initialize .
.
.
.
.
.
.
interpolate .
.
.
.
.
intersect
.
.
.
.
.
isLonLat .
KML .
.
.
.
.
.
.
.
.
layerize .
.
.
.
.
layerStats .
.
.
localFun .
.
.
Logic-methods
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
4
R topics documented:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
mask .
.
.
.
match .
.
.
.
Math-methods .
.
.
.
.
merge .
.
.
.
.
.
metadata .
.
.
.
.
.
modal
.
.
.
.
mosaic .
.
.
.
.
.
movingFun .
.
.
.
.
names .
.
.
.
.
.
NAvalue .
.
.
.
ncell .
.
.
.
.
.
.
.
.
nlayers .
.
.
.
.
.
Options
.
.
.
.
origin .
.
.
.
overlay .
.
.
.
.
.
.
.
pairs .
.
.
.
.
.
persp .
.
.
.
.
plot
.
.
.
.
plotRGB .
.
.
.
.
pointDistance .
.
.
predict .
.
.
.
Programming .
.
.
.
projection .
.
.
projectRaster
.
.
.
.
.
properties .
.
.
.
.
.
quantile .
.
.
.
raster
.
.
.
.
.
Raster-class .
.
.
.
rasterFromCells .
.
rasterFromXYZ .
.
rasterize .
.
.
.
rasterTmpFile .
.
.
rasterToContour .
rasterToPoints .
.
.
rasterToPolygons .
readAll
.
.
.
reclassify .
.
rectify .
.
.
replacement
resample .
.
.
.
resolution .
.
.
.
RGB .
.
.
rotate
.
rotated .
.
.
.
round .
.
.
rowFromCell
.
.
rowSums
SampleInt
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
R topics documented:
5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
sampleRandom .
sampleRegular
.
sampleStratified .
.
.
.
scale .
.
.
.
.
scalebar
.
.
.
select
.
.
.
setExtent
.
.
.
setMinMax .
.
.
.
setValues
.
.
.
shapefile .
.
shift
.
.
.
Slope and aspect
.
.
.
sp .
.
.
.
spplot
.
.
stack .
.
.
.
stackApply .
.
.
.
stackSave .
.
.
.
stackSelect
.
.
stretch .
.
.
.
.
.
.
subset
.
.
.
.
.
.
substitute .
Summary .
.
.
.
Summary-methods
.
.
symdif .
.
.
terrain .
.
.
text
.
.
transpose
.
.
.
.
trim .
.
.
.
.
union .
.
.
unique .
.
.
unstack .
.
.
.
update .
.
.
validCell .
.
validNames .
.
weighted.mean .
which .
.
.
.
which.min .
.
writeFormats
.
writeRaster
.
writeValues .
.
.
.
xyFromCell
.
.
.
z-values .
.
.
.
.
zApply .
zonal .
.
.
.
.
.
.
.
.
.
zoom .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
.
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
.
Index
230
6
raster-package
raster-package
Overview of the functions in the raster package
Description
The raster package provides classes and functions to manipulate geographic (spatial) data in ’raster’
format. Raster data divides space into cells (rectangles; pixels) of equal size (in units of the coor-
dinate reference system). Such continuous spatial data are also referred to as ’grid’ data, and be
contrasted with discrete (object based) spatial data (points, lines, polygons).
The package should be particularly useful when using very large datasets that can not be loaded
into the computer’s memory. Functions will work correctly, because they they process large files in
chunks, i.e., they read, compute, and write blocks of data, without loading all values into memory
at once.
Below is a list of some of the most important functions grouped by theme. See the vignette for more
information and some examples (you can open it by running this command: vignette(’Raster’))
Details
The package implements classes for Raster data (see Raster-class) and supports
• Creation of Raster* objects from scratch or from file
• Handling extremely large raster files
• Raster algebra and overlay functions
• Distance, neighborhood (focal) and patch functions
• Polygon, line and point to raster conversion
• Model predictions
• Summarizing raster values
• Easy access to raster cell-values
• Plotting (making maps)
• Manipulation of raster extent, resolution and origin
• Computation of row, col and cell numbers to coordinates and vice versa
• Reading and writing various raster file types
.
I. Creating Raster* objects
RasterLayer, RasterStack, and RasterBrick objects are, as a group, referred to as Raster* objects.
Raster* objects can be created, from scratch, files, or from objects of other classes, with the follow-
ing functions:
raster
stack
brick
To create a RasterLayer
To create a RasterStack (multiple layers)
To create a RasterBrick (multiple layers)
raster-package
7
subset
addLayer
dropLayer
unstack
————————— —————————————————————————————————
Select layers of a RasterStack/Brick
Add a layer to a Raster* object
Remove a layer from a RasterStack or RasterBrick
Create a list of RasterLayer objects from a RasterStack
II. Changing the spatial extent and/or resolution of Raster* objects
merge
mosaic
crop
extend
trim
aggregate
disaggregate
resample
projectRaster
shift
flip
rotate
t
————————— ——————————————————————————————
Combine Raster* objects with different extents (but same origin and resolution)
Combine RasterLayers with different extents and a function for overlap areas
Select a geographic subset of a Raster* object
Enlarge a Raster* object
Trim a Raster* object by removing exterior rows and/or columns that only have NAs
Combine cells of a Raster* object to create larger cells
Subdivide cells
Warp values to a Raster* object with a different origin or resolution
project values to a raster with a different coordinate reference system
Move the location of Raster
Flip values horizontally or vertically
Rotate values around the date-line (for lon/lat data)
Transpose a Raster* object
III. Raster algebra
Arith-methods
Math-methods
Logic-methods
Summary-methods
Compare-methods
————————— ——————————————————————————————
Arith functions (+, -, *, ^, %%, %/%, /)
Math functions like abs, sqrt, trunc, log, log10, exp, sin, round
Logic functions (!, &, |)
Summary functions (mean, max, min, range, prod, sum, any, all)
Compare functions (==, !=, >, <, <=, >=)
IV. Cell based computation
calc
overlay
cover
mask
cut
subs
Computations on a single Raster* object
Computations on multiple RasterLayer objects
First layer covers second layer except where the first layer is NA
Use values from first Raster except where cells of the mask Raster are NA
Reclassify values using ranges
Reclassify values using an ’is-becomes’ matrix
8
raster-package
reclassify
init
stackApply
stackSelect
————————— ——————————————————————————————
Reclassify using a ’from-to-becomes’ matrix
Initialize cells with new values
Computations on groups of layers in Raster* object
Select cell values from different layers using an index RasterLayer
V. Spatial contextual computation
Shortest distance to a cell that is not NA
distance
Distance when traversing grid cells that are not NA
gridDistance
distanceFromPoints
Shortest distance to any point in a set of points
Direction (azimuth) to or from cells that are not NA
direction
focal
Focal (neighborhood; moving window) functions
localFun
Local association (using neighborhoods) functions
boundaries
Detection of boundaries (edges)
clump
Find clumps (patches)
adjacent
Identify cells that are adjacent to a set of cells on a raster
area
Compute area of cells (for longitude/latitude data)
terrain
Compute slope, aspect and other characteristics from elevation data
Moran
Compute global or local Moran or Geary indices of spatial autocorrelation
————————— ——————————————————————————————
VI. Model predictions
predict
interpolate
————————— ——————————————————————————————
Predict a non-spatial model to a RasterLayer
Predict a spatial model to a RasterLayer
VII. Data type conversion
You can coerce Raster* objects to Spatial* objects using as, as in as(object, ’SpatialGridDataFrame’)
raster
rasterize
rasterToPoints
rasterToPolygons
rasterToContour
rasterFromXYZ
RasterLayer from SpatialGrid*, image, or matrix objects
Rasterizing points, lines or polygons
Create points from a RasterLayer
Create polygons from a RasterLayer
Contour lines from a RasterLayer
RasterLayer from regularly spaces points