raster (version 1.1.7)

Function writing: Helper functions to use in new functions you develop

Description

low level functions for programmers 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(raster, n=4)
closeConnection(raster)
openConnection(raster, silent=FALSE)
pbCreate(nsteps, type, style=3)
pbStep(pb, step=NULL, label='step')
pbClose(pb, time=FALSE)

Arguments

raster
a RasterLayer object
n
the number of copies of a RasterLayer object with values that a function needs to store 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))
type
Character. 'text', 'tcltk', or 'windows'
style
style for text progress bar. See txtProgressBar
pb
a progress bar object created with pbCreate
step
which step is this ( 1 <= step="" <="nsteps" ).="" if="" is="" NULL, a single step is taken
label
label for the non-text progress bars
time
Logical. If TRUE, time to completion will be printed

Value

  • canProcessInMemory: logical closeHandle: RasterLayer 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 DataCamp Workspace