ENVI {caMassClass}R Documentation

Read and write binary data in ENVI format

Description

Read and write binary data in ENVI format, which is supported by most GIS software.

Usage

   read.ENVI(filename, headerfile=paste(filename, ".hdr", sep="")) 
  write.ENVI(X, filename, interleave = c("bsq", "bil", "bip")) 

Arguments

X data to be saved in ENVI file. Can be a matrix or 3D array.
filename character string with name of the file (connection)
headerfile optional character string with name of the header file
interleave optional character string specifying interleave to be used

Details

ENVI binary files use a generalized raster data format that consists of two parts:

Fields samples, lines, bands, data type are required, while header offset, interleave, byte order are optional. All of them are in form of integers except interleave which is a string.

This generic format allows reading of many raw file formats, including those with embedded header information. Also it is a handy binary format to exchange data between PC and UNIX/Mac machines, as well as different languages like: C, Fortran, Matlab, etc. Especially since header files are simple enough to edit by hand.

File type supported by most of GIS (geographic information system) software including: ENVI software, Freelook (free file viewer by ENVI), ArcGIS, etc.

Value

Function read.ENVI returns either a matrix or 3D array. Function write.ENVI does not return anything.

Author(s)

Jarek Tuszynski (SAIC) jaroslaw.w.tuszynski@saic.com

See Also

readBin, writeBin

Examples

  X = array(1:60, 3:5)
  write.ENVI(X, "temp.nvi")
  Y = read.ENVI("temp.nvi")
  stopifnot(X == Y)
  readLines("temp.nvi.hdr")
  
  d = c(20,30,40)
  X = array(runif(prod(d)), d)
  write.ENVI(X, "temp.nvi", interleave="bil")
  Y = read.ENVI("temp.nvi")
  stopifnot(X == Y)
  readLines("temp.nvi.hdr")
  
  file.remove("temp.nvi")
  file.remove("temp.nvi.hdr")

[Package caMassClass version 1.0 Index]