create_blank_raster: Create an empty raster and header.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/create_blank_raster.R

Description

This function creates an arbitrarily large raster as a flat binary file with (optionally) a proper header for use with other functions. This should create the blank files very quickly, as it is using some OS tricks to carve out a block of space rather than writing a bunch of 0s to disk sequentially.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
create_blank_raster(
  filename = NULL,
  format = "raster",
  datatype = "FLT8S",
  bandorder = "BSQ",
  nrow = NULL,
  ncol = NULL,
  nlayers = NULL,
  create_header = TRUE,
  reference_raster = NULL,
  return_filename = TRUE,
  additional_header = NULL,
  overwrite = FALSE,
  verbose = FALSE
)

Arguments

filename

Character. The output base filename of the blank file. Will use tempfile() if nothing is provided.

format

Character. Output format. Currently only supports "raster".

datatype

Character. Output number type. See ?dataType. Default is "FLT8S".

bandorder

Character. Output band interleave. Currently only supports "BSQ".

nrow

Numeric. Number of rows of the output raster. Defaults to nrow(reference_raster).

ncol

Numeric. Number of columns of the output raster. Defaults to ncol(reference_raster).

nlayers

Numeric. Number of layers of the output raster Defaults to nlayer(reference_raster).

create_header

Logical. Create a properly formatted header for the blank file?

reference_raster

Raster*. Reference raster to derive other information, e.g. resolution, projection, datum.

return_filename

Logical. Return filename of the binary file (if TRUE, default) or the Raster* itself (if FALSE).

additional_header

Character. Create additional output headers for use with other GIS systems (see hdr). Set to NULL (default) to suppress.

overwrite

Logical. Overwrite an existing file with the same name?

verbose

Logical. Enable verbose execution? Default is FALSE.

Details

create_blank_raster is designed to quickly create a binary file of the appropriate size using tricks with seek()/writeBin(). A large file can be created in a fraction of a second using this function. This file could, for example, be used with mmap to realize asynchronous or, OS permitting, parallel writes to a single file. Note that setMinMax are NOT performed on the output file (to save time), so on some systems you may see a warning.

Binary files of this type are used by a number of raster formats, including raster and ENVI.

Value

A character vector (return_filename==TRUE) or as Raster* object (return_filename==TRUE)

Author(s)

Jonathan A. Greenberg

See Also

hdr

Examples

1
2
3
4
5
6
7
8
## Not run:  
tahoe_highrez <- brick(system.file("external/tahoe_highrez.tif", package="spatial.tools"))
test_blank_file <- create_blank_raster(reference_raster=tahoe_highrez)
file.info(test_blank_file)
test_blank_raster <- create_blank_raster(reference_raster=tahoe_highrez,return_filename=FALSE)
test_blank_raster

## End(Not run)

spatial.tools documentation built on Feb. 14, 2020, 1:07 a.m.