1

Does anyone have any idea about getting the map info from an ENVI header file?

This is my file.hdr as shown in the text editor:

ENVI
description = {
C:\xxxx\yyyy\Desktop\filename.}
samples = 36000
lines   = 36000
bands   = 1
header offset = 0
file type = ENVI Standard
data type = 4
interleave = bsq
byte order = 0
map info = {Geographic Lat/Lon, 1, 1, 20, 28, 0.000222222222222222, 0.000222222222222222,WGS-84}
coordinate system string = {GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]}
band names = {
Band 1}

I would like to use the "pixel easting" (20), "pixel northing" (28) and "pixel dimension" (0.000222) in a python script. Is there any Python library about that? It seems like a simple matter, but I still can't get through it.

1 Answer 1

0

You can use spectral https://www.spectralpython.net/index.html

It is a python package for processing hyperspectral image data. It can read ENVI header file. Asimple code could be:

import spectral.io.envi as envi

lib = envi.open("file.hdr")
map_info = lib.metadata["map info"]

# this assumes that the params you are looking for are at 3,4,5 position
pix_easting = map_info[3]
pix_northing = map_info[4]
pix_dim = map_info[5]

print(pix_easting, pix_northing, pix_dim)  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.