This is a reference to a raster metadata object. You have two options to get a reference to an ENVIRasterMetadata object:
- Create a reference to a new, empty object that contains no metadata information.
- An existing ENVIRaster object's METADATA property contains a reference to the populated ENVIRasterMetadata object associated with the ENVIRaster 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.
e = ENVI()
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
metadata = raster.METADATA
PRINT, metadata
PRINT, metadata.TAGS
metadata.AddItem, 'Author', 'OldCompanyName'
metadata.UpdateItem, 'Author', 'NewCompanyName'
metadata.UpdateItem, 'band names', $
['Blue', 'Green', 'Red', 'NIR']
PRINT, metadata
metadata.RemoveItem, 'Author'
PRINT, metadata
The next example creates a new, empty metadata object.
PRO CreateNewMetadataObject
COMPILE_OPT IDL2
e = ENVI()
metadata = ENVIRasterMetadata()
metadata.AddItem, 'Author', 'OldCompanyName'
metadata.UpdateItem, 'Author', 'NewCompanyName'
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:
e = ENVI(/HEADLESS)
File = Filepath('qb_boulder_msi', Subdir=['data'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
metadataTags = Raster.Metadata.Tags
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