Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rasterTmpFile

Temporary files


Description

Functions in the raster package create temporary files if the values of an output Raster* object cannot be stored in memory (RAM). This can happen when no filename is provided to a function and in functions where you cannot provide a filename (e.g. when using 'raster algebra').

Temporary files are automatically removed at the start of each session. During a session you can use showTmpFiles to see what is there and removeTmpFiles to delete all the temporary files. rasterTmpFile returns a temporary filename. These can be useful when developing your own functions. These filenames consist of prefix_date_time_pid_rn where pid is the process id returned by Sys.getpid and rn is a 5 digit random number. This should make tempfiles unique if created at different times and also when created in parallel processes (different pid) that use set.seed and call rasterTmpFile at the same time. It is possible, however, to create overlapping names (see the examples), which is undesirable and can be avoided by setting the prefix argument.

Usage

rasterTmpFile(prefix='r_tmp_')
showTmpFiles()
removeTmpFiles(h=24)

Arguments

prefix

Character. Prefix to the filename (which will be followed by 10 random numbers)

h

Numeric. The minimum age of the files in number of hours (younger files are not deleted)

Value

rasterTmpFile returns a valid file name

showTmpFiles returns the names (.grd only) of the files in the temp directory

removeTmpFiles returns nothing

See Also

Examples

## Not run: 
rasterTmpFile('mytemp_')
showTmpFiles()
removeTmpFiles(h=24)

## End(Not run)

raster

Geographic Data Analysis and Modeling

v3.4-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Jacob van Etten [ctb], Michael Sumner [ctb], Joe Cheng [ctb], Dan Baston [ctb], Andrew Bevan [ctb], Roger Bivand [ctb], Lorenzo Busetto [ctb], Mort Canty [ctb], Ben Fasoli [ctb], David Forrest [ctb], Aniruddha Ghosh [ctb], Duncan Golicher [ctb], Josh Gray [ctb], Jonathan A. Greenberg [ctb], Paul Hiemstra [ctb], Kassel Hingee [ctb], Institute for Mathematics Applied Geosciences [cph], Charles Karney [ctb], Matteo Mattiuzzi [ctb], Steven Mosher [ctb], Babak Naimi [ctb], Jakub Nowosad [ctb], Edzer Pebesma [ctb], Oscar Perpinan Lamigueiro [ctb], Etienne B. Racine [ctb], Barry Rowlingson [ctb], Ashton Shortridge [ctb], Bill Venables [ctb], Rafael Wueest [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.