spatial.tools (version 1.6.0)

binary_image_write: Writes image data to a flat binary file using col/row/band positioning.

Description

Writes image data to a flat binary file using col/row/band positioning.

Usage

binary_image_write(filename, mode = real64(), image_dims,
  interleave = "BSQ", data, data_position)

Arguments

filename

Character. The path and filename of a "blank" binary file to store the image data.

mode

The mode of data on disk. Defaults to real64() (double precision floating point).

image_dims

Vector. Vector of length(image_dims)==3 representing the number of columns, rows and bands in the output image.

interleave

Character. The require output interleave. By default is "BSQ". OTHER INTERLEAVES CURRENTLY UNSUPPORTED.

data

Vector, matrix, array, or other data source which is coercible to a vector. This is the data to be written to the image.

data_position

List. A length==3 list, containing the column, row, and band positions ranges to write the output data.

See Also

mmap,create_blank_raster

Examples

Run this code
# NOT RUN {
tahoe_highrez <- brick(system.file("external/tahoe_highrez.tif", package="spatial.tools"))
# Create a blank file using create_blank_raster
test_blank_file <- create_blank_raster(reference_raster=tahoe_highrez)
blank_raster <- brick(test_blank_file)
# It should be all 0s:
setMinMax(blank_raster)
# Write some ones to to the 100th line, columns 25 to 50, bands 1 and 3:
data_position <- list(25:50,100,c(1,3))
data1s <- array(1,dim=c(
	length(data_position[[1]]),
	length(data_position[[2]]),
	length(data_position[[3]])))
plot(raster(test_blank_file,layer=1))
binary_image_write(filename=test_blank_file,
	mode=real64(),image_dims=dim(tahoe_highrez),interleave="BSQ",
	data=data1s,data_position=data_position)
setMinMax(blank_raster)
plot(raster(blank_raster,layer=1))
# }

Run the code above in your browser using DataLab