ENVIRasterMetadata

This is a reference to a raster metadata object. You have two options to get a reference to an ENVIRasterMetadata object:

See The ENVI Header Format for a list of standard metadata tags in ENVI-format rasters.

The following tags are reserved and cannot be used with the AddItem, RemoveItem, and UpdateItem methods: bands, band names (cannot be removed using RemoveItem), byte order, coordinate system string, data type, file type, geo points, header offset, interleave, lines, map info, pixel size, projection info, rpc info, and samples.

To save metadata changes to disk, use the ENVIRaster::WriteMetadata method.

Example

The following code opens a file that returns an ENVIRaster and prints all available metadata tag names and values.

; Launch the application

e = ENVI()

 

; Create an ENVIRaster

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

SUBDIRECTORY = ['data'])

raster = e.OpenRaster(file)

 

; Print all metadata values

metadata = raster.METADATA

PRINT, metadata ; print tag names and values

PRINT, metadata.TAGS ; print string array of tag names

 

; Add, then update, a user-defined item

metadata.AddItem, 'Author', 'OldCompanyName'

metadata.UpdateItem, 'Author', 'NewCompanyName'

 

; Update a format-defined item

metadata.UpdateItem, 'band names', $

  ['Blue', 'Green', 'Red', 'NIR']

 

; Print the updated metadata values

PRINT, metadata

 

; Remove an item

metadata.RemoveItem, 'Author'

PRINT, metadata

The next example creates a new, empty metadata object.

PRO CreateNewMetadataObject

COMPILE_OPT IDL2

 

; Launch the application

e = ENVI()

 

; create a new metadata object

metadata = ENVIRasterMetadata()

 

; Add, then update, a user-defined item

metadata.AddItem, 'Author', 'OldCompanyName'

metadata.UpdateItem, 'Author', 'NewCompanyName'

 

; Print the updated metadata values

PRINT, metadata

 

END

See More Examples.

Syntax

Result = ENVIRasterMetadata([, Keywords=value] [, Properties=value])

Use brackets to retrieve metadata values, using the following syntax. Type the metadata field exactly as it appears in the above table.

var = metadata['field name']

Methods

AddItem

Dehydrate

HasTag

Hydrate

RemoveItem

UpdateItem

Keywords

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.

Properties

Properties marked as (Get) can be retrieved, but not set.

COUNT (Get)

A long integer that represents the number of available tags.

TAGS (Get)

A string array of tag names used to retrieve metadata items. Metadata tags are defined by the file format from which the ENVIRaster was opened. Consult your data provider or file format specification for more information on metadata fields for specific sensors and/or data formats (GeoTIFF, NITF, and others).

More Examples

The following example uses raster metadata to determine if it is a classification raster:

; Start the application

e = ENVI(/HEADLESS)

 

; Open an input file

File = Filepath('qb_boulder_msi', Subdir=['data'], $

  Root_Dir=e.Root_Dir)

Raster = e.OpenRaster(File)

 

; Access metadata tags

metadataTags = Raster.Metadata.Tags

 

; If these three tags exist, the raster is a classification raster

isClassRaster = metadataTags.HasValue(['CLASSES','CLASS NAMES','CLASS LOOKUP'])

Version History

ENVI 5

Introduced

ENVI 5.0.2

Added cloud cover, solar irradiance, sun azimuth, and sun elevation fields

ENVI 5.1

Added ability for ENVIRasterMetadata to serve as a constructor function for creating new metadata objects.

ENVI 5.3.1

Added Dehydrate method

ENVI 5.4

Added Hydrate method

API Version

4.2

See Also

ENVIRaster, Raster Metadata, EditRasterMetadata Task, ENVIRaster::WriteMetadata