This method has been deprecated. Please refer to ENVIRaster.

The CreateRaster function method creates a new ENVIRaster that is ready for writing to a file. See ENVIRaster::SetData and ENVIRaster::SetTile for additional ways to provide data to the new ENVIRaster.

Example


; Launch the application
e = ENVI()
 
; Create an ENVIRaster
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
  SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file) 
 
; Create an output raster
newFile = e.GetTemporaryFilename()
 
; Retrieve data from original raster that contains only a single band
origData = raster.GetData(BANDS=0)
 
; Create raster and save it in newFile
newRaster = e.CreateRaster(newFile, origData, NBANDS=1)
newRaster.Save

Syntax


Result = ENVI.CreateRaster(URI [, Data] [, DATA_IGNORE_VALUE=value] [, DATA_TYPE=variable] [, ERROR=variable] [, INHERITS_FROM=ENVIRaster] [, INTERLEAVE=string] [, METADATA= ENVIRasterMetadata][, NBANDS=variable] [, NCOLUMNS=variable] [, NROWS=variable] [, SPATIALREF=ENVISpatialRef] [, TIME=ENVITime])

Return Value


This method returns a reference to an ENVIRaster.

Arguments


URI

A scalar string that is a fully-qualified file path to a new ENVI Standard format file to which the raster data should be written.

Data

A two-dimensional or three-dimensional array of data. When the Data argument is a three-dimensional array, use the INTERLEAVE keyword to specify the interleave of the raster.

If the Data is specified, then the values for the NBANDS, NCOLUMNS, NROWS, and DATA_TYPE keywords are taken from Data. If Data is not specified, the NBANDS, NCOLUMNS, NROWS, and DATA_TYPE keywords have precedence over the values in the INHERITS_FROM raster, if it is specified.

If you do not specify Data, an empty ENVIRaster object is created; however, you must specify either (1) INHERITS_FROM or (2) NBANDS, NROWS, NCOLUMNS, and DATA_TYPE. You can then use ENVIRaster::SetData or ENVIRaster::SetTile to add data to the ENVIRaster.

Keywords


Keywords are applied only during the initial creation of the object.

DATA_IGNORE_VALUE

Set this keyword to a pixel value that will be ignored when the raster is displayed. This overrides any data ignore values set in the metadata.

DATA_TYPE

Set this keyword to an integer or string specifying the raster data type (strings are not case-sensitive):

String Value Data Type Bit Length
byte 1 Byte 8
double 5 Double-precision floating point 64
float 4 Floating point 32
int 2 Integer 16
long 3 Long integer 32
uint 12 Unsigned integer 16
ulong 13 Unsigned long integer 32

If Data is provided, this keyword is ignored.

ERROR

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

INHERITS_FROM

Set this keyword to an ENVIRaster from which all metadata and the following properties will be copied: DATA_TYPE, INTERLEAVE, NCOLUMNS, and NROWS.

Data acquisition time (from the ENVIRaster TIME property) will not be copied.

Since new rasters are often created as the output of processing an input raster, they typically have the same spatial and spectral dimensions, interleave, and data type as the input raster. The INHERITS_FROM keyword provides convenience in inheriting these properties. If you do not specify the INHERITS_FROM keyword, you must either provide the Data argument and INTERLEAVE is assumed to be 'bsq' if not set, or specify the BANDS, NCOLUMNS, DATA_TYPE, and NROWS keywords when calling the CreateRaster method.

See ENVIRasterMetadata for details on creating and modifying metadata.

Note: If both the SPATIALREF and INHERITS_FROM keywords are specified, the spatial reference information from SPATIALREF takes precedence.

INTERLEAVE

When the Data argument is a three-dimensional array, set this keyword to a string specifying the interleave of the raster:

String Interleave Data Array
bil Band interleaved by line [ncolumns, nbands, nrows]
bip Band interleaved by pixel [nbands, ncolumns, nrows]
bsq Band sequential [ncolumns, nrows, nbands]

This keyword is optional and the default value 'bsq' is used if it is not set. This keyword has no effect when the Data argument is a two-dimensional array.

METADATA

Set this keyword to an ENVIRasterMetadata object, which provides the metadata information for the newly created ENVIRaster.

Note: If both the METADATA and INHERITS_FROM keywords are specified, the metadata information from METADATA takes precedence.

Note: The DATA_IGNORE_VALUE keyword takes precedence over the METADATA keyword.

NBANDS

Set this keyword to the number of bands in the raster dataset. If Data is provided, this keyword is ignored.

NCOLUMNS

Set this keyword to the number of columns in the raster dataset. If Data is provided, this keyword is ignored.

NROWS

Set this keyword to the number of rows in the raster dataset. If Data is provided, this keyword is ignored.

SPATIALREF

Set this keyword to an ENVIRasterSpatialRefPseudo, ENVIRasterSpatialRefRPC, or ENVIRasterSpatialRefStandard object, which provides the spatial reference information for the newly-created ENVIRaster.

Note: If both the SPATIALREF and INHERITS_FROM keywords are specified, the spatial reference information from SPATIALREF takes precedence.

TIME

Set this keyword to an ENVITime object, which provides the acquisition time of the raster. See The ENVI Header Format for details of how the time string is formatted.

Version History


ENVI 5

Introduced

ENVI 5.0.2

Added TIME keyword

ENVI 5.1

Deprecated

See Also


ENVI function, ENVIRaster::SetData, ENVIRaster::SetTile, ENVIView::CreateLayer, ENVI::CreateRasterSpatialRef, ENVIRasterMetadata