build_testraster: build_testraster

Description Usage Arguments Value Note Examples

View source: R/build_testraster.R

Description

helper function used to quickly create a rasterStack object with specified dimensions (useful for testing purposes).

Usage

1
2
build_testraster(nrows = 100, ncols = 100, nbands = 1,
  with_nodata = TRUE, to_file = FALSE, out_file = NULL, ...)

Arguments

nrows

numeric number of rows, Default: 100

ncols

numeric number of columns, Default: 100

nbands

numeric number of bands, Default: 1

with_nodata

PARAM_DESCRIPTION, Default: TRUE

to_file

logical if TRUE, the rasterStack is saved to a TIFF file, Default: FALSE

out_file

character filename where the test raster should be saved (ignored if to_file = NULL). If out_file is NULL, the file is saved in R temporary folder, otherwise the filename specified in out_file is used. In both cases, the name of the created TIFF file is returned instead than the rasterStack itself, Default: NULL.

...

Any other arguments to be passed to raster::raster while creating the output raster.

Value

Either the "test" raster in rasterStack format, or the filename where it was saved (if tofile = TRUE)

Note

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
 # create a rasterstack of 100*100 cells and 10 bands and put it in test_rast
 test_rast <- build_testraster(100,100,10)
 test_rast

 # create a rasterstack of 100*100 cells and 20 bands and save it to a temporary TIFF file
 test_rast <- build_testraster(100,100,20, to_file = TRUE)
 test_rast

 # create a rasterstack of 100*100 cells and 10 in epsg:3857 projection on a given extent
 build_testraster(100,100,10, crs = "+init=epsg:3857",
                              ext = raster::extent(c(0, 200000, 0, 200000)))
 test_rast

## End(Not run)

IREA-CNR-MI/sprawl documentation built on Aug. 6, 2017, 12:56 p.m.