Learn R Programming

raster (version 2.1-25)

Programming: Helper functions for programming

Description

These are low level functions that can be used by programmers to develop new functions. If in doubt, it is almost certain that you do not need these as these functions are already embedded in all other functions in the raster package. canProcessInMemory is typically used within functions. In the raster package this function is used to determine if the amount of memory needed for the function is available. If there is not enough memory available, the function returns FALSE, and the function that called it will write the results to a temporary file. openConnection opens a file connection for reading, closeConnection removes it. pbCreate creates a progress bar, pbStep sets the progress, and pbClose closes it.

Usage

canProcessInMemory(x, n=4)
closeConnection(x)
openConnection(x, silent=FALSE)
pbCreate(nsteps, progress, style=3, label='Progress', ...)
pbStep(pb, step=NULL, label='')
pbClose(pb, timer)
getCluster()
returnCluster()

Arguments

x
RasterLayer or RasterBrick object (for connections) or RasterStack object (canProcessInMemory)
n
integer. The number of copies of the Raster* object cell values that a function needs to be able to have in memory
silent
logical. passed on to GDAL.open
nsteps
integer. Number of steps the progress bar will make from start to end (e.g. nrow(raster))
progress
character. 'text', 'window', or ''
style
style for text progress bar. See txtProgressBar
label
character. Label for the window type prograss bar
...
additional arguments (None implemented)
pb
progress bar object created with pbCreate
step
which step is this ( 1 <= step="" <="nsteps" ).="" if="" is="" NULL, a single step is taken
timer
logical. If TRUE, time to completion will be printed. If missing, the value will be taken from the rasterOptions

Value

  • canProcessInMemory: logical closeConnection: RasterLayer or RasterBrick object getCluster: snow cluster object

Examples

Run this code
r <- raster(nrow=100, ncol=100)
canProcessInMemory(r, 4)
r <- raster(nrow=100000, ncol=100000)
canProcessInMemory(r, 2)

Run the code above in your browser using DataLab