Why two ENVI header files are different?

2 views (last 30 days)
Devendra
Devendra on 25 Apr 2024
Answered: Abhas on 22 May 2024
I have generated ENVI header file using MATLAB code is as follows;
map_info = sprintf('UTM, %f, %f, %f, %f, %f, %f, %s, %s, units=Meters', ...
R.XIntrinsicLimits(1), R.YIntrinsicLimits(1), ...
R.XWorldLimits(1), R.YWorldLimits(2), ...
R.CellExtentInWorldX, R.CellExtentInWorldY, ...
R.ColumnsStartFrom, R.CoordinateSystemType);
This is giving following map info
{UTM, 0.500000, 0.500000, 699960.000000, 3300000.000000, 10.000000, 10.000000, north, planar, units=Meters}
While ENVI software generated map info is as follows
map info = {UTM, 1.000, 1.000, 699960.000, 3300000.000, 2.0000000000e+001, 2.0000000000e+001, 43, North, WGS-84, units=Meters}
I request you to please suggest me why this difference has occured and how to get map info generated by ENVI software by using MATLAB.
Devendra

Answers (1)

Abhas
Abhas on 22 May 2024
Hi Devendra,
The difference between the map info generated by your MATLAB code and the one generated by ENVI software is due to the starting pixel reference, pixel size, zone number, and the datum used. The detailed causes of this differences are:
  1. Starting Pixel Reference: ENVI uses a starting pixel reference of (1,1) by default, indicating the top-left corner of the image as the first pixel. The MATLAB code specifies (0.5, 0.5) to represent the center of the top-left pixel.
  2. Pixel Size: The MATLAB code specifies a pixel size of 10x10 meters, while the ENVI output shows a pixel size of 20x20 meters. This indicates a discrepancy in the spatial resolution of the dataset as interpreted in each environment.
  3. Zone Number: The ENVI output includes 43, which specifies the UTM zone number (43) but the MATLAB code doesn't directly correspond to this value.
  4. Datum: ENVI specifies the datum (WGS-84), which is a standard global datum for Earth whereas MATLAB code does not include this information.
Here's the MATLAB code that can be reffered to fix the differences:
% Assuming `zone` variable contains the UTM zone number (43)
% and `hemisphere` variable contains 'North'.
map_info = sprintf('UTM, 1.000, 1.000, %f, %f, 20.000000, 20.000000, %d, %s, WGS-84, units=Meters', ...
R.XWorldLimits(1), R.YWorldLimits(2), ...
zone, hemisphere);
By making these adjustments, you should be able to generate map info that more closely matches the ENVI software output.
You may refer to the following documentation links to have a better understanding on reading the metadata from an ENVI header file:
  1. https://www.mathworks.com/help/images/ref/enviinfo.html
  2. https://www.mathworks.com/help/images/ref/hypercube.html

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!