
Last chance! 50% off unlimited learning
Sale ends in
vignette('Raster')
)raster
To create a RasterLayer
stack
To create a RasterStack (multiple layers)
brick
To create a RasterBrick (multiple layers)
addLayer
Add a layer to a Raster* object
dropLayer
Remove a layer from a RasterStack or RasterBrick
unstack
Create a list of RasterLayer objects from a RasterStack
}
RasterLayer, RasterStack, and RasterBrick objects are, as a group, referred to as Raster* objectsmerge
Combine Raster* objects with different extents (but same origin and resolution)
mosaic
Combine RasterLayers with different extents and a function to set values in overlap areas
crop
Select a geographic subset of a Raster* object
expand
Enlarge a Raster* object
trim
Trim a Raster* object by removing exterior rows and/or columns that only have NA values
aggregate
Combine cells of a Raster* object to create larger cells
disaggregate
Subdivide cells
resample
Warp values to a Raster* object with a different origin or resolution
projectRaster
Warp values to a Raster* object with a different coordinate reference system
shift
Move the location of Raster
flip
Flip values horizontally or vertically
rotate
Rotate values around the date-line (for lon/lat data)
t
Transpose a Raster* object
}Arith-methods
Arith functions (+, -, *, ^, %%, %/%, /
)
Math-methods
Math functions (abs, sqrt, trunc, log, log10, exp, sin, round
among others)
Logic-methods
Logic functions (!, &, |
)
Summary-methods
Summary functions (mean, max, min, range, prod, sum, any, all
)
Compare-methods
Compare functions (==, !=, >, <, <=",">=
)
}calc
Computations on a single Raster* object
overlay
Computations on multiple RasterLayer objects
cover
First layer covers second layer except where the first layer is NA
mask
Use values from first Raster except where cells of the mask Raster are NA (these become NA)
cut
Reclassify values using ranges
subs
Reclassify values using a 'is-becomes' matrix
reclass
Reclassify using a 'from-to-becomes' matrix
init
Initialize cells with new values
stackApply
Computations on groups of layers in Raster* object
stackSelect
Select cell values from different layers using an index RasterLayer
}distance
Shortest distance to a cell that is not NA
gridDistance
Distance when traversing grid cells that are not NA
distanceFromPoints
Shortest distance to any point in a set of points
direction
Direction (azimuth) to or from cells that are not NA
focal
Focal (neighborhood; moving window) functions
edge
Edge detection
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
}predict
Predict a non-spatial model to a RasterLayer
interpolate
Predict a spatial model to a RasterLayer
}rasterize
Rasterizing points, lines or polygons
rasterToPoints
Create points from a RasterLayer
rasterToPolygons
Create polygons from a RasterLayer
rasterToContour
Contour lines from a RasterLayer
rasterFromXYZ
RasterLayer from regularly spaces points
rasterFromCells
RasterLayer from a Raster object and cell numbers
raster
RasterLayer from SpatialGrid*, image, or matrix objects
}
You can coerce Raster* objects to Spatial* objects using as
, as in as(object, 'SpatialGridDataFrame')
cellStats
Summarize a Raster cell values with a function
summary
Summary of the values of a Raster* object (quartiles and mean)
freq
Frequency table of Raster cell values
count
Count the frequency of a single (range of) value(s)
crosstab
Cross-tabulate two RasterLayer objects, or mulitple layers in a RasterStack/Brick
unique
Get the unique values in a Raster* object
zonal
Summarize a Raster* object by zones in a RasterLayer
}getValues
Get all cell values (fails with very large rasters), or a row of values (safer)
getValuesBlock
Get values for a block (a rectangular area defined by start and end row and column
getValuesFocal
Get focal values for one or more rows
as.matrix
Get cell values as a matrix
as.array
Get cell values as an array
extract
Extract cell values from a Raster* object (e.g., by cell, coordinates, polygon)
sampleRandom
Random sample
sampleRegular
Regular sample
minValue
Get the minimum value of the cells of a Raster* object (not always known)
maxValue
Get the maximum value of the cells of a Raster* object (not always known)
setMinMax
Compute the minimum and maximum value of a Raster* object if these are not known
}
You can also use indexing with [
for cell numbers, and [[
for row / column number combinationsplot
Plot a Raster* object. The main method to create a map
plotRGB
Combine three layers (red, green, blue channels) into a single 'real color' image
spplot
Plot a Raster* with the spplot function (sp package)
image
Plot a Raster* with the image function
persp
Perspective plot of a RasterLayer
contour
Contour plot of a RasterLayer
filledContour
Filled contour plot of a RasterLayer
text
Plot the values of a RasterLayer on top of a map
}
The rasterVis packages has additional plotting methods for Raster objects using methods from the lattice package and from other packages.
Interacting with a map (plot of a RasterLayer)
zoom
Zoom in on a plot of a RasterLayer
click
Draw points and/or query values of RasterLayer by clicking on a map
drawPoly
Create a SpatialPolygons object by drawing it
drawLine
Create a SpatialLines object by drawing it
drawExtent
Create an Extent object by drawing it
}
Other plots
plot
x-y scatter plot of values of two RasterLayer objects
hist
Histogram of Raster* object values
density
Density plot of Raster* object values
pairs
Pairs plot for layers in a RasterStack or RasterBrick
boxplot
Box plot of the values of one or multiple layers
}ncol
The number of columns
nrow
The number of rows
ncell
The number of cells (can not be set directly, only via ncol or nrow)
res
The resolution (x and y)
nlayers
How many layers does the object have?
names
Get or set the layer names
xres
The x resolution (can be set with res)
yres
The y resolution (can be set with res)
xmin
The minimum x coordinate (or longitude)
xmax
The maximum x coordinate (or longitude)
ymin
The minimum y coordinate (or latitute)
ymax
The maximum y coordinate (or latitute)
extent
The extent (minimum and maximum x and y coordinates)
origin
The origin of a Raster* object
projection
The coordinate reference system (map projection)
isLonLat
Test if an object has a longitude/latitude coordinate reference system
filename
Filename to which a RasterLayer or RasterBrick is linked
band
Band (layer) of a multi-band file that this RasterLayer is linked to
nbands
How many bands (layers) does the file have?
compare
Compare for equality the basic parameters of two Raster* objects
NAvalue
Get or set the NA
value (for reading from file; see writeRaster for setting it when writing a file)
}
If there are values associated with a RasterLayer object (either in memory or via a link to a file) these are lost when you change the number of columns or rows or the resolution. This is not the case when the extent is changed (as the number of columns and rows will not be affected). Simlarly, with projection you can set the projection, but this does not transform the data (see projectRaster for that).xFromCol
x-coordinates from column numbers
yFromRow
y-coordinates from row numbers
xFromCell
x-coordinates from row numbers
yFromCell
y-coordinates from cell numbers
xyFromCell
x and y coordinates from cell numbers
colFromX
Column numbers from x-coordinates (or longitute)
rowFromY
Row numbers from y-coordinates (or latitute)
cellFromXY
Cell numbers from x and y coordinates
cellFromRowCol
Cell numbers from row and column numbers
cellsFromExtent
Cell numbers from extent object
coordinates
x and y coordinates for all cells
validCell
Is this a valid cell number?
validCol
Is this a valid column number?
validRow
Is this a valid row number?
}setValues
Put new values in a Raster* object
writeRaster
Write all values of Raster* object to disk
KML
Save raster as KML file
}
Advanced writing of entire files or parts thereof
blockSize
Get suggested block size for reading and writing
writeStart
Open a file for writing
writeValues
Write some values
writeStop
Close the file after writing
update
Change the values of an existing file
}extent
Create an extent object
intersect
Intersect two extent objects
union
Combine two extent objects
round
round/floor/ceiling of the coordinates of an Extent object
alignExtent
Align an extent with a Raster* object
drawExtent
Create an Extent object by drawing it on top of a map (see plot)
}
You can also use S4 type coercion such as as(extent, 'SpatialPolygons')
setOptions
Set session options
showOptions
Show session options
saveOptions
Save session options to make them persistent
clearOptions
Set session options to default values
}getData
Download and geographic data
pointDistance
Distance between points
readIniFile
Read a (windows) 'ini' file
hdr
Write header file for a number of raster formats
trim
Remove leading and trainling blanks from a character string
extension
Get or set the extentsion of a filename
cv
Coefficient of variation
modal
Modal value
sampleInt
Random sample of (possibly very large) range of integer values
showTmpFiles
Show temporary files
removeTmpFiles
Remove temporary files
}canProcessInMemory
Test whether a file can be created in memory
pbCreate
Initialize a progress bar
pbStep
Take a progress bar step
pbClose
Close a progress bar
openConnection
Open a file connection
closeConnection
Close a file connection
rasterTmpFile
Get a name for a temporary file
inMemory
Are the cell values in memory?
fromDisk
Are the cell values read from a file?
}