This task sets metadata values for a raster file and writes a header file (.hdr) to disk. If a previous ENVI header file (.hdr) exists with the raster, this task overrides all of its metadata values.

Tip: For rasters that already have an associated header file, use the ENVIRasterMetadata::UpdateItem method to edit metadata fields, then use the ENVIRaster::Save method to save the updates to the header file on disk.

Example


; Start the application
e = ENVI()
 
; Generate raster data.
data = Bytarr(500,500,3)
data[*,*,0] = Bytscl(Dist(500))
data[*,*,1] = Shift(Bytscl(Dist(500)),167,167)
data[*,*,2] = Shift(Bytscl(Dist(500)),334,334)
 
; Save the data to a raster object.
raster = ENVIRaster(data)
raster.Save
filename = raster.URI
 
; Get the task from the catalog of ENVITasks
Task = ENVITask('SetRasterMetadata')
 
; Define required metadata
Task.INPUT_RASTER = raster
Task.BYTE_ORDER = 'Network (IEEE)'
Task.DATA_TYPE = 'Byte'
Task.FILE_TYPE = 'ENVI'
Task.INTERLEAVE = 'BSQ'
Task.NBANDS = 3
Task.NCOLUMNS = 500
Task.NROWS = 500
 
; Define optional metadata
Task._DESCRIPTION = 'This is a test image.'
 
; Run the task
Task.Execute
 
; When the task runs, it closes the raster in order to 
; create the header file. Re-open the raster.
raster = e.OpenRaster(filename)
 
; Display the result
View1 = e.GetView()
Layer1 = View1.CreateLayer(raster)

Syntax


Result = ENVITask('SetRasterMetadata')

Input properties (Set, Get): ACQUISITION_TIME, AUXILIARY_RPC_SPATIALREF, BAND_NAMES, BBL, BYTE_ORDER, CLASS_LOOKUP, CLASS_NAMES, CLASSES, CLOUD_COVER, COLOR_TABLE, COMPLEX_FUNCTION, DATA_GAIN_VALUES, DATA_IGNORE_VALUE, DATA_OFFSET_VALUES, DATA_REFLECTANCE_GAIN_VALUES, DATA_REFLECTANCE_OFFSET_VALUES, DATA_TYPE, DEFAULT_BANDS, DEFAULT_STRETCH, DEM_BAND, DEM_FILE, _DESCRIPTION, FILE_TYPE, FWHM, HEADER_LOCATION, HEADER_OFFSET, INPUT_RASTER, INTERLEAVE, NBANDS, NCOLUMNS, NROWS, OUTPUT_RASTER_URI, PRODUCT_TYPE, READ_PROCEDURES, REFLECTANCE_SCALE_FACTOR, SECURITY_TAG, SENSOR_TYPE, SOLAR_IRRADIANCE, SPATIALREF, SUN_AZIMUTH, SUN_ELEVATION, WAVELENGTH, WAVELENGTH_UNITS, X_START, Y_START, Z_PLOT_RANGE, Z_PLOT_TITLES

Output properties (Get only): OUTPUT_RASTER

Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.

Methods


This task inherits the following methods from ENVITask:

AddParameter

Execute

Parameter

ParameterNames

RemoveParameter

Properties


This task inherits the following properties from ENVITask:

COMMUTE_ON_DOWNSAMPLE

COMMUTE_ON_SUBSET

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

This task also contains the following properties:

ACQUISITION_TIME (optional)

Specify a string with the acquisition time, conforming to the ISO-8601 standard. The string can be in any of the following formats:

YYYY-MM-DD
YYYY-MM-DDTHH:MM:SS.DZ
YYYY-MM-DDTHH:MM:SS:Dooo:mm

Where:

  • YYYY is the four-digit year
  • MM is the two-digit month
  • DD is the two-digit day
  • T separates the date and time
  • HH is the two-digit hour
  • MM is the two-digit minute
  • SS is the two-digit second
  • D is the decimal fraction of a second with up to double-precision
  • Z indicates that the time is in Coordinate Universal Time (UTC)
  • ooo is a two-digit offset in hours from UTC time. If the offset is negative, a minus symbol (-) precedes the value.
  • mm is an optional partial-hour offset (in minutes) from UTC time.

AUXILIARY_RPC_SPATIALREF (optional)

Specify an ENVIRPCRasterSpatialRef object that provides secondary map information (if any) for the raster, in addition to its standard map information.

BAND_NAMES (optional)

Specify a string array with the names of raster bands.

BBL (optional)

Specify an integer array with the same number of elements as BAND_NAMES, where 0 indicates a bad band and 1 indicates a good band. This property is typically used with hyperspectral imagery.

BYTE_ORDER (required)

Specify one of the following strings, indicating the byte order of the raster:

  • Host (Intel): Least significant byte first; typically DEC and MS-DOS systems
  • Network (IEEE): Most significant byte first; all other platforms

This property applies to imagery with integer, long integer, 64-bit integer, unsigned 64-bit integer, floating point, double precision, and complex data types.

CLASS_LOOKUP (optional)

Specify a (3, n) byte array, where n is the number of classes, with RGB color definitions for each class in a classification file. For example, black is [0,0,0].

CLASS_NAMES (optional)

Specify a string array of class names in a classification file, where the number of elements must equal the number of classes.

CLASSES (optional)

Specify an unsigned integer value with the number of classes (including unclassified regions) in a classification file.

CLOUD_COVER (optional)

Specify a floating-point value (0 to 100.0) with the percentage of cloud cover within the raster.

COLOR_TABLE (optional)

Specify a (3, 256) byte array representing the full color table to use when displaying this raster.

COMPLEX_FUNCTION (optional)

Specify one of the following strings indicating the values to calculate from a raster with a complex data type. This will also determine what to use for displaying the image, for calculating statistics for the image, or for writing the image to a new file.

Power
Magnitude
Real
Imaginary
Phase

DATA_GAIN_VALUES (optional)

Specify a double-precision array of gain values for each band. Units are W/(m2 * µm * sr).

DATA_IGNORE_VALUE (optional)

Specify an integer indicating the pixel value that should be ignored in image processing.

DATA_OFFSET_VALUES (optional)

Specify a double-precision array of offset values for each band.

DATA_REFLECTANCE_GAIN_VALUES (optional)

Specify a double-precision array of reflectance gain values.

DATA_REFLECTANCE_OFFSET_VALUES (optional)

Specify a double-precision array of reflectance offset values.

DATA_TYPE (required)

Specify one of the following strings indicating the data type of the raster pixel data:

Byte
Integer
Long Integer
Float
Double
Complex
Double-precision Complex
Unsigned Integer
Unsigned Long Integer
64-bit Long Integer
64-bit Unsigned Long Integer

DEFAULT_BANDS (optional)

Specify an unsigned integer array of band numbers to automatically load into the current view every time the raster is opened.

DEFAULT_STRETCH (optional)

Specify one of the following strings indicating the stretch to apply when ENVI display the raster:

equalization
gaussian
linear range
logarithmic
optimized linear
x % linear (for example, 5% linear)
square root

DEM_BAND (optional)

Specify an unsigned integer indicating the index (starting at 1) of a selected DEM band associated with the raster, as indicated by the DEM_FILE property. If the DEM file contains a single band, or if you choose the first band of the input raster, the DEM_BAND value defaults to 0.

DEM_FILE (optional)

Specify a string with the fully qualified path and filename of a DEM associated with the raster.

_DESCRIPTION (optional)

Specify a string that describes the image or the processing performed.

FILE_TYPE (required)

Specify one of the following strings indicating the file format of the raster:

BIL
Custom
DTED
ENVI
ENVI Meta File
GDB
GRID
HDF5
IMAGINE
JPEG
JPEG2000
MrSID
NITF
SERIES
TIFF

FWHM (optional)

Specify a double-precision array of full-width-half-maximum (FWHM) values of each band in the raster.

HEADER_LOCATION (required)

Specify one of the following strings indicating where to save the associated header file (.hdr) after setting the raster metadata:

  • Same as raster file (default)
  • Auxiliary File Directory: The directory specified in the Auxiliary File Directory field of the ENVI preferences file.

HEADER_OFFSET (required)

Specify an unsigned integer value with the number of bytes of embedded header information present in the file. ENVI skips these bytes when reading the file. The default value is 0.

INPUT_RASTER (required)

Specify a raster on which to set the metadata values.

INTERLEAVE (required)

Specify one of the following strings indicating the data interleave of the raster. The default is BSQ.

BSQ
BIL
BIP

NBANDS (required)

Specify an unsigned integer with the number of bands in the raster.

NCOLUMNS (required)

Specify an unsigned integer with the number of columns in the raster.

NROWS (required)

Specify an unsigned integer with the number of lines in the raster.

OUTPUT_RASTER (optional)

Updating the header file requires closing the raster. Use this property to reopen and return a reference to the raster.

OUTPUT_RASTER_URI (optional)

Specify a string with the fully qualified filename and path of the associated OUTPUT_RASTER. If you do not specify this property, or set it to an exclamation symbol (!), a temporary file will be created.

PRODUCT_TYPE (optional)

Specify one of the following strings indicating the product type, if the raster is a DigitalGlobe dataset:

Basic Product
Stereo Product
Standard Product
Orthorectified Product
Digital Elevation Model Product

For Suomi NPP VIIRS datasets:

SDR
EDR

READ_PROCEDURES (optional)

Specify a two-element string array with the names of spatial and spectral read routines for ENVI Classic file readers.

REFLECTANCE_SCALE_FACTOR (optional)

Specify a floating-point value that, when divided into the pixel data, would scale it from 0-1 reflectance. For example, if the value of 10,000 in the pixel data represents a reflectance value of 1.0, enter a reflectance scale factor of 10,000.

SECURITY_TAG (optional)

Specify a string with security information inherited from formats that typically contain security classification levels (such as NITF).

SENSOR_TYPE (optional)

Specify one of the following strings, indicating the sensor type of the input raster. Strings are case-sensitive.

Unknown
WorldView-2
SPOT
QuickBird
RapidEye
Landsat ETM+
Landsat TM
Landsat MSS
WorldView-1
GeoEye-1
IKONOS
OrbView-3
KOMPSAT-2
CARTOSAT-1
Landsat ETM
Landsat OLI
Landsat TIR
AATSR
ADAR
ADEOS
ADRG
Air Photo
AIRSAR
AISA
ALOS
ASAR
ASTER
AVHRR
AVIRIS
CASI
COSMO-SkyMed
DMC
DMSP
EROS
ERS
FORMOSAT-2
GER63
GEOSCAN
HYDICE
HyMap
Hyperion
IRS LISSIII
IRS Pan
IRS WIFS
JERS-1
MAS
MASTER
MERIS
MIVIS
MODIS
MOMS-02
RADARSAT
RADARSAT-2
Scanned Image
SEAWIFS
SEBASS
SIR-C
SPIN-2
TIMS
TMS
TRWIS III
USGS DEM
X-SAR
PLEIADES-1A
DUBAISAT-1
EO-1 ALI
EO-1 Hyperion
NPP VIIRS
ResourceSat2 AWiFS
ResourceSat2 LISS-III
ResourceSat2 LISS-IV
SSOT
UK-DMC
UK DMC2
NIGERIASAT
BEIJING
ALSAT
DEIMOS-1
NIGERIASAT-2
KOMPSAT-3
SPOT-6
PLEIADES-1B
GOKTURK-2
RASAT
SkySat-1
ZY3-1
GF-1
ZY-1-02C
WORLDVIEW-3
PROBA-V
ALSAT-2A
VNREDSAT-1

SOLAR_IRRADIANCE (optional)

Specify a double-precision array of top-of-atmosphere solar irradiance values per band. Units are W/(m2 * µm).

SPATIALREF (optional)

Specify an ENVIPseudoRasterSpatialRef, ENVIRPCRasterSpatialRef, or ENVIStandardRasterSpatialRef object that indicates the spatial reference of the raster.

SUN_AZIMUTH (optional)

Specify a double-precision value with the angle of the sun (in degrees) from due north in a clockwise direction.

SUN_ELEVATION (optional)

Specify a double-precision value with the angle of the sun (in degrees) above the horizon.

WAVELENGTH (optional)

Specify a double-precision array that lists the center wavelength values of each band in an image. Units should be the same as those used for the FWHM property and also set in the WAVELENGTH_UNITS parameter.

WAVELENGTH_UNITS (optional)

Specify one of the following strings indicating the units of the wavelengths in the WAVELENGTH property. The default value is Nanometers.

Micrometers
Nanometers
Wavenumber
GHz
MHz
Index
Unknown

X_START (required)

Specify an unsigned integer with the X image coordinate for the upper-left pixel in the image. Images that are spatial subsets of larger images often use an image coordinate system that references the parent (or larger) image so that you can link and dynamically overlay the two images. The default value is 0.

Y_START (required)

Specify an unsigned integer with the the Y image coordinate for the upper-left pixel in the image. Images that are spatial subsets of larger images often use an image coordinate system that references the parent (or larger) image so that you can link and dynamically overlay the two images. The default value is 0.

Z_PLOT_RANGE (optional)

Specify a two-element double-precision array with the default minimum and maximum values for Z (spectral) plots.

Z_PLOT_TITLES (optional)

Specify a two-element string array with the X-axis and Y-axis titles for Z (spectral) plots.

Version History


ENVI 5.3

Introduced

ENVI 5.5

Changed the OUTPUT_RASTER_URI parameter to be required.

ENVI 5.7 Added the COLOR_TABLE property.

API Version


4.2

See Also


ENVITask, EditRasterMetadata task, ENVISubsetRaster, ENVIRasterMetadata, ENVIRaster::WriteMetadata, ENVIRaster::Save, Raster Metadata (ENVI API Programming), ENVIParameterENVISensorName::GetSensorList