ENVIRaster::SetData

This method sets data on an ENVIRaster that is open for writing. Access the READ_ONLY property on the ENVIRaster to determine if you can write to the ENVIRaster.

Example

; Launch the application

e = ENVI()

 

; Open the original data set

file = FILEPATH('qb_boulder_pan', ROOT_DIR=e.ROOT_DIR, $

SUBDIRECTORY = ['data'])

raster = e.OpenRaster(file)

 

; Retrieve all data from the original raster

origData = raster.GetData()

 

; Get a subset of data from the original raster

subsetData = raster.GetData(SUB_RECT=[200,200,299,299])

 

; Create a new raster from the original

newFile = e.GetTemporaryFilename()

newRaster = ENVIRaster(origData, URI=newfile, INHERITS_FROM=raster)

 

; Lighten up a portion of the data by adding to the pixel value

newRaster.SetData, subsetData+300, SUB_RECT=[200,200,299,299]

newRaster.Save

 

; Display the new dataset

view = e.GetView()

layer = view.CreateLayer(newRaster)

Syntax

ENVIRaster.SetData, Data [, Keywords=value]

Arguments

Data

An array of data to be written to the ENVIRaster. If Data is a three-dimensional array, it must have the same interleave as the ENVIRaster. The data type will be converted to match that of the DATA_TYPE property of the ENVIRaster if it is not already the same.

Keywords

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

BANDS

An array of integer indices that define the spectral subset to be set. The indices are sequential and zero-based (Band 1 = 0, Band 2 = 1, and so on). By default, all bands are included.

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.

SUB_RECT

Set this keyword to a four-element array expressing the spatial range (in pixels) of the data. The array is of the form [x1, y1, x2, y2], where:

x1 = First pixel of the columns dimension

y1 = First pixel of the rows dimension

x2 = Last pixel of the columns dimension

y2 = Last pixel of the rows dimension

Pixel coordinates are zero-based.

If you want to use a subset of the input data for image processing, consider using the ENVISubsetRaster function instead.

Version History

ENVI 5

Introduced

API Version

4.2

See Also

ENVIRaster, ENVIRaster::GetData, ENVIRaster::Save, ENVIRaster::SetTile, ENVISubsetRaster