Ability to write any ENVI header fields set using SetMetadata
|Reported by:||robintw||Owned by:||warmerdam|
|Severity:||normal||Keywords:||envi metadata raster|
The ability to read all fields from the ENVI header was added in http://trac.osgeo.org/gdal/ticket/4735. To go with that, GDAL really should have an ability to write any of these fields back out to an ENVI header file.
The metadata that has been read from the header file by GDAL (using the new code added through the ticket linked above) is put in the ENVI metadata domain. Thus, a sensible (and fairly simple - I think) way to implement this would be to loop through all of the metadata items set within the ENVI domain and simply write them all out to the header file. From what I know of ENVI header files (although I may be wrong), the order of the items in the file doesn't matter, so the code could simply append to the end of the file, with each appended line being:
KEY = VALUE
where KEY is the metadata item name with _'s replaced by spaces and VALUE is the string value of the metadata.
This would allow the metadata read in via GDAL from one image to be easily written out to another image, and would also allow users to specify their own metadata to add to the ENVI file (eg. they could manually add a metadata field with sensor_type set to "Amazing Simulated Image" if they wanted, and it would appear as the Sensor Type in ENVI).
What do people think?