comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: reading envi file in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: reading envi file in IDL [message #55512] Thu, 23 August 2007 13:26
Jeff N. is currently offline  Jeff N.
Messages: 120
Registered: April 2005
Senior Member
On Aug 23, 4:09 pm, robinson....@gmail.com wrote:
> On Aug 23, 12:29 pm, "Jeff N." <jnett...@utk.edu> wrote:
>
>
>
>> On Aug 23, 2:14 pm, robinson....@gmail.com wrote:
>
>>> Hi Jean, thanks for your assistance. I got this error:
>>> Error occurred at: READ_BINARY 132 C:\RSI\IDL63\lib
>>> \read_binary.pro
>>> Robinson
>
>>> On Aug 23, 10:49 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
>>> wrote:
>
>>>> Robin,
>
>>>> if you just have this one file, you can do:
>
>>>> data = read_binary('c:\test\yourFile',data_Start = 0,data_Type=4,
>>>> data_Dims=[400,400,5])
>
>>>> From the top of my head, I can't remember where/how to specify the band
>>>> interleave.... though in your case you have the default option, so it
>>>> would work!
>
>>>> If you have other files, I can send you/here a function that, with the
>>>> help of ENVI, opens the file and return the header info in a structure...
>
>>>> Jean
>
>>>> > Dear All,
>>>> > I created a file using ENVI and its header file is below. Does
>>>> > somebody could show me how to read that file in IDL?
>>>> > In advance thank you very much
>>>> > Robinson Juarez
>
>>>> > =======================================
>>>> > ENVI
>>>> > description = {
>>>> > File Resize Result, x resize factor: 1.000000, y resize factor:
>>>> > 1.000000.
>>>> > [Wed Aug 22 10:02:17 2007]}
>>>> > samples = 400
>>>> > lines = 400
>>>> > bands = 5
>>>> > header offset = 0
>>>> > file compression = 1
>>>> > file type = ENVI Standard
>>>> > data type = 4
>>>> > interleave = bsq
>>>> > sensor type = Unknown
>>>> > byte order = 0
>>>> > x start = 1323
>>>> > y start = 714
>>>> > map info = {UTM, 1.000, 1.000, 694231.500, 9759973.000, 2.8500000000e
>>>> > +001, 2.8500000000e+001, 20, South, WGS-84, units=Meters}
>>>> > wavelength units = Unknown
>>>> > band names = {
>>>> > Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:GV (X:4278 Y:
>>>> > 1152):MAO20071001_test1.em),
>>>> > Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:NPV (X:6152 Y:
>>>> > 928):MAO20071001_test1.em),
>>>> > Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SOIL (X:5959 Y:
>>>> > 4199):MAO20071001_test1.em),
>>>> > Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SHADE (X:2359 Y:
>>>> > 2415):MAO20071001_test1.em),
>>>> > Resize (RMS Error:MAO20071001_test1.em)}
>>>> > ============================================================ ======
>
>> I really think you need to figure out what's going on with the file
>> compression issue. The code I posted for you will work for normal
>> (uncompressed) envi images - i've used code like this many, many, many
>> times myself.
>
>> Jeff
>
> Jeff, you were right. The "file compression =1" was the issue. The /
> Compress keyword in the opening procedure solved the problem.
> Robinson

Good deal...i was puzzled by that compression setting, i'd never heard
of it being done before. Glad you got it worked out!

Jeff
Re: reading envi file in IDL [message #55513 is a reply to message #55512] Thu, 23 August 2007 13:16 Go to previous message
robinson.inj is currently offline  robinson.inj
Messages: 32
Registered: August 2007
Member
Thank you very much Mike. That works
Robinson


On Aug 23, 12:46 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
> On Aug 23, 11:55 am, robinson....@gmail.com wrote:
>
>> Jeff, I tried that before post my ad., but did not work.
>> Robinson
>
> This is basically a guess, but try:
>
> im = fltarr(400, 400, 5)
> openr, lun, filename, /get_lun, /compress, /swap_if_big_endian
> readu, lun, im
> free_lun, lun
>
> Besides the compression, I think everything is correct. My guess is to
> just try the COMPRESS keyword and hope it works. I don't have a data
> file to try this on, so let me know what happens.
>
> Mike
> --www.michaelgalloy.com
Re: reading envi file in IDL [message #55514 is a reply to message #55513] Thu, 23 August 2007 13:09 Go to previous message
robinson.inj is currently offline  robinson.inj
Messages: 32
Registered: August 2007
Member
On Aug 23, 12:29 pm, "Jeff N." <jnett...@utk.edu> wrote:
> On Aug 23, 2:14 pm, robinson....@gmail.com wrote:
>
>
>
>> Hi Jean, thanks for your assistance. I got this error:
>> Error occurred at: READ_BINARY 132 C:\RSI\IDL63\lib
>> \read_binary.pro
>> Robinson
>
>> On Aug 23, 10:49 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
>> wrote:
>
>>> Robin,
>
>>> if you just have this one file, you can do:
>
>>> data = read_binary('c:\test\yourFile',data_Start = 0,data_Type=4,
>>> data_Dims=[400,400,5])
>
>>> From the top of my head, I can't remember where/how to specify the band
>>> interleave.... though in your case you have the default option, so it
>>> would work!
>
>>> If you have other files, I can send you/here a function that, with the
>>> help of ENVI, opens the file and return the header info in a structure...
>
>>> Jean
>
>>>> Dear All,
>>>> I created a file using ENVI and its header file is below. Does
>>>> somebody could show me how to read that file in IDL?
>>>> In advance thank you very much
>>>> Robinson Juarez
>
>>>> =======================================
>>>> ENVI
>>>> description = {
>>>> File Resize Result, x resize factor: 1.000000, y resize factor:
>>>> 1.000000.
>>>> [Wed Aug 22 10:02:17 2007]}
>>>> samples = 400
>>>> lines = 400
>>>> bands = 5
>>>> header offset = 0
>>>> file compression = 1
>>>> file type = ENVI Standard
>>>> data type = 4
>>>> interleave = bsq
>>>> sensor type = Unknown
>>>> byte order = 0
>>>> x start = 1323
>>>> y start = 714
>>>> map info = {UTM, 1.000, 1.000, 694231.500, 9759973.000, 2.8500000000e
>>>> +001, 2.8500000000e+001, 20, South, WGS-84, units=Meters}
>>>> wavelength units = Unknown
>>>> band names = {
>>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:GV (X:4278 Y:
>>>> 1152):MAO20071001_test1.em),
>>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:NPV (X:6152 Y:
>>>> 928):MAO20071001_test1.em),
>>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SOIL (X:5959 Y:
>>>> 4199):MAO20071001_test1.em),
>>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SHADE (X:2359 Y:
>>>> 2415):MAO20071001_test1.em),
>>>> Resize (RMS Error:MAO20071001_test1.em)}
>>>> ============================================================ ======
>
> I really think you need to figure out what's going on with the file
> compression issue. The code I posted for you will work for normal
> (uncompressed) envi images - i've used code like this many, many, many
> times myself.
>
> Jeff


Jeff, you were right. The "file compression =1" was the issue. The /
Compress keyword in the opening procedure solved the problem.
Robinson
Re: reading envi file in IDL [message #55517 is a reply to message #55514] Thu, 23 August 2007 12:46 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Aug 23, 11:55 am, robinson....@gmail.com wrote:
> Jeff, I tried that before post my ad., but did not work.
> Robinson

This is basically a guess, but try:

im = fltarr(400, 400, 5)
openr, lun, filename, /get_lun, /compress, /swap_if_big_endian
readu, lun, im
free_lun, lun

Besides the compression, I think everything is correct. My guess is to
just try the COMPRESS keyword and hope it works. I don't have a data
file to try this on, so let me know what happens.

Mike
--
www.michaelgalloy.com
Re: reading envi file in IDL [message #55520 is a reply to message #55517] Thu, 23 August 2007 12:29 Go to previous message
Jeff N. is currently offline  Jeff N.
Messages: 120
Registered: April 2005
Senior Member
On Aug 23, 2:14 pm, robinson....@gmail.com wrote:
> Hi Jean, thanks for your assistance. I got this error:
> Error occurred at: READ_BINARY 132 C:\RSI\IDL63\lib
> \read_binary.pro
> Robinson
>
> On Aug 23, 10:49 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
> wrote:
>
>> Robin,
>
>> if you just have this one file, you can do:
>
>> data = read_binary('c:\test\yourFile',data_Start = 0,data_Type=4,
>> data_Dims=[400,400,5])
>
>> From the top of my head, I can't remember where/how to specify the band
>> interleave.... though in your case you have the default option, so it
>> would work!
>
>> If you have other files, I can send you/here a function that, with the
>> help of ENVI, opens the file and return the header info in a structure...
>
>> Jean
>
>>> Dear All,
>>> I created a file using ENVI and its header file is below. Does
>>> somebody could show me how to read that file in IDL?
>>> In advance thank you very much
>>> Robinson Juarez
>
>>> =======================================
>>> ENVI
>>> description = {
>>> File Resize Result, x resize factor: 1.000000, y resize factor:
>>> 1.000000.
>>> [Wed Aug 22 10:02:17 2007]}
>>> samples = 400
>>> lines = 400
>>> bands = 5
>>> header offset = 0
>>> file compression = 1
>>> file type = ENVI Standard
>>> data type = 4
>>> interleave = bsq
>>> sensor type = Unknown
>>> byte order = 0
>>> x start = 1323
>>> y start = 714
>>> map info = {UTM, 1.000, 1.000, 694231.500, 9759973.000, 2.8500000000e
>>> +001, 2.8500000000e+001, 20, South, WGS-84, units=Meters}
>>> wavelength units = Unknown
>>> band names = {
>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:GV (X:4278 Y:
>>> 1152):MAO20071001_test1.em),
>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:NPV (X:6152 Y:
>>> 928):MAO20071001_test1.em),
>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SOIL (X:5959 Y:
>>> 4199):MAO20071001_test1.em),
>>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SHADE (X:2359 Y:
>>> 2415):MAO20071001_test1.em),
>>> Resize (RMS Error:MAO20071001_test1.em)}
>>> ============================================================ ======

I really think you need to figure out what's going on with the file
compression issue. The code I posted for you will work for normal
(uncompressed) envi images - i've used code like this many, many, many
times myself.

Jeff
Re: reading envi file in IDL [message #55523 is a reply to message #55520] Thu, 23 August 2007 11:14 Go to previous message
robinson.inj is currently offline  robinson.inj
Messages: 32
Registered: August 2007
Member
Hi Jean, thanks for your assistance. I got this error:
Error occurred at: READ_BINARY 132 C:\RSI\IDL63\lib
\read_binary.pro
Robinson


On Aug 23, 10:49 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> Robin,
>
> if you just have this one file, you can do:
>
> data = read_binary('c:\test\yourFile',data_Start = 0,data_Type=4,
> data_Dims=[400,400,5])
>
> From the top of my head, I can't remember where/how to specify the band
> interleave.... though in your case you have the default option, so it
> would work!
>
> If you have other files, I can send you/here a function that, with the
> help of ENVI, opens the file and return the header info in a structure...
>
> Jean
>
>> Dear All,
>> I created a file using ENVI and its header file is below. Does
>> somebody could show me how to read that file in IDL?
>> In advance thank you very much
>> Robinson Juarez
>
>> =======================================
>> ENVI
>> description = {
>> File Resize Result, x resize factor: 1.000000, y resize factor:
>> 1.000000.
>> [Wed Aug 22 10:02:17 2007]}
>> samples = 400
>> lines = 400
>> bands = 5
>> header offset = 0
>> file compression = 1
>> file type = ENVI Standard
>> data type = 4
>> interleave = bsq
>> sensor type = Unknown
>> byte order = 0
>> x start = 1323
>> y start = 714
>> map info = {UTM, 1.000, 1.000, 694231.500, 9759973.000, 2.8500000000e
>> +001, 2.8500000000e+001, 20, South, WGS-84, units=Meters}
>> wavelength units = Unknown
>> band names = {
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:GV (X:4278 Y:
>> 1152):MAO20071001_test1.em),
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:NPV (X:6152 Y:
>> 928):MAO20071001_test1.em),
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SOIL (X:5959 Y:
>> 4199):MAO20071001_test1.em),
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SHADE (X:2359 Y:
>> 2415):MAO20071001_test1.em),
>> Resize (RMS Error:MAO20071001_test1.em)}
>> ============================================================ ======
Re: reading envi file in IDL [message #55524 is a reply to message #55523] Thu, 23 August 2007 10:55 Go to previous message
robinson.inj is currently offline  robinson.inj
Messages: 32
Registered: August 2007
Member
On Aug 23, 10:48 am, "Jeff N." <jnett...@utk.edu> wrote:
> On Aug 23, 12:09 pm, robinson....@gmail.com wrote:
>
>
>
>> Dear All,
>> I created a file using ENVI and its header file is below. Does
>> somebody could show me how to read that file in IDL?
>> In advance thank you very much
>> Robinson Juarez
>
>> =======================================
>> ENVI
>> description = {
>> File Resize Result, x resize factor: 1.000000, y resize factor:
>> 1.000000.
>> [Wed Aug 22 10:02:17 2007]}
>> samples = 400
>> lines = 400
>> bands = 5
>> header offset = 0
>> file compression = 1
>> file type = ENVI Standard
>> data type = 4
>> interleave = bsq
>> sensor type = Unknown
>> byte order = 0
>> x start = 1323
>> y start = 714
>> map info = {UTM, 1.000, 1.000, 694231.500, 9759973.000, 2.8500000000e
>> +001, 2.8500000000e+001, 20, South, WGS-84, units=Meters}
>> wavelength units = Unknown
>> band names = {
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:GV (X:4278 Y:
>> 1152):MAO20071001_test1.em),
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:NPV (X:6152 Y:
>> 928):MAO20071001_test1.em),
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SOIL (X:5959 Y:
>> 4199):MAO20071001_test1.em),
>> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SHADE (X:2359 Y:
>> 2415):MAO20071001_test1.em),
>> Resize (RMS Error:MAO20071001_test1.em)}
>> ============================================================ ======
>
> Well, if you look at the ENVI help files you'll see what all these
> header values mean. The dimensions of the image are the samples,
> lines, and bands. The bsq interleave tells you that the dimensions
> are (400,400,5). The data type of 4 means float data (i'm pretty
> sure, double check this). Header offset = 0 means the binary file is
> all data, no header bytes.
>
> So, in this case it would normally boil down to a simple readu:
>
> img = fltarr(400,400,5)
> openr, lun, image_file_name, /get_lun
> readu, lun, img
> free_lun, lun
>
> I say it *would* boil down to the code above b/c i've never seen the
> "file compression = 1" line in an envi header. If the file is
> compressed you're going to have to deal with the compression, however
> that was done.
>
> Also check to make sure the byte order matches your machine (if you
> created the image file on the same machine you're reading it with, it
> shouldn't be an issue).
>
> Hope that helps,
> Jeff



Jeff, I tried that before post my ad., but did not work.
Robinson
Re: reading envi file in IDL [message #55525 is a reply to message #55524] Thu, 23 August 2007 10:49 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Robin,

if you just have this one file, you can do:

data = read_binary('c:\test\yourFile',data_Start = 0,data_Type=4,
data_Dims=[400,400,5])

From the top of my head, I can't remember where/how to specify the band
interleave.... though in your case you have the default option, so it
would work!

If you have other files, I can send you/here a function that, with the
help of ENVI, opens the file and return the header info in a structure...

Jean


> Dear All,
> I created a file using ENVI and its header file is below. Does
> somebody could show me how to read that file in IDL?
> In advance thank you very much
> Robinson Juarez
>
> =======================================
> ENVI
> description = {
> File Resize Result, x resize factor: 1.000000, y resize factor:
> 1.000000.
> [Wed Aug 22 10:02:17 2007]}
> samples = 400
> lines = 400
> bands = 5
> header offset = 0
> file compression = 1
> file type = ENVI Standard
> data type = 4
> interleave = bsq
> sensor type = Unknown
> byte order = 0
> x start = 1323
> y start = 714
> map info = {UTM, 1.000, 1.000, 694231.500, 9759973.000, 2.8500000000e
> +001, 2.8500000000e+001, 20, South, WGS-84, units=Meters}
> wavelength units = Unknown
> band names = {
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:GV (X:4278 Y:
> 1152):MAO20071001_test1.em),
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:NPV (X:6152 Y:
> 928):MAO20071001_test1.em),
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SOIL (X:5959 Y:
> 4199):MAO20071001_test1.em),
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SHADE (X:2359 Y:
> 2415):MAO20071001_test1.em),
> Resize (RMS Error:MAO20071001_test1.em)}
> ============================================================ ======
>
Re: reading envi file in IDL [message #55526 is a reply to message #55525] Thu, 23 August 2007 10:48 Go to previous message
Jeff N. is currently offline  Jeff N.
Messages: 120
Registered: April 2005
Senior Member
On Aug 23, 12:09 pm, robinson....@gmail.com wrote:
> Dear All,
> I created a file using ENVI and its header file is below. Does
> somebody could show me how to read that file in IDL?
> In advance thank you very much
> Robinson Juarez
>
> =======================================
> ENVI
> description = {
> File Resize Result, x resize factor: 1.000000, y resize factor:
> 1.000000.
> [Wed Aug 22 10:02:17 2007]}
> samples = 400
> lines = 400
> bands = 5
> header offset = 0
> file compression = 1
> file type = ENVI Standard
> data type = 4
> interleave = bsq
> sensor type = Unknown
> byte order = 0
> x start = 1323
> y start = 714
> map info = {UTM, 1.000, 1.000, 694231.500, 9759973.000, 2.8500000000e
> +001, 2.8500000000e+001, 20, South, WGS-84, units=Meters}
> wavelength units = Unknown
> band names = {
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:GV (X:4278 Y:
> 1152):MAO20071001_test1.em),
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:NPV (X:6152 Y:
> 928):MAO20071001_test1.em),
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SOIL (X:5959 Y:
> 4199):MAO20071001_test1.em),
> Resize (Unmix (amazonas_p231r062_etm_071001_a5) EM:SHADE (X:2359 Y:
> 2415):MAO20071001_test1.em),
> Resize (RMS Error:MAO20071001_test1.em)}
> ============================================================ ======

Well, if you look at the ENVI help files you'll see what all these
header values mean. The dimensions of the image are the samples,
lines, and bands. The bsq interleave tells you that the dimensions
are (400,400,5). The data type of 4 means float data (i'm pretty
sure, double check this). Header offset = 0 means the binary file is
all data, no header bytes.

So, in this case it would normally boil down to a simple readu:

img = fltarr(400,400,5)
openr, lun, image_file_name, /get_lun
readu, lun, img
free_lun, lun

I say it *would* boil down to the code above b/c i've never seen the
"file compression = 1" line in an envi header. If the file is
compressed you're going to have to deal with the compression, however
that was done.

Also check to make sure the byte order matches your machine (if you
created the image file on the same machine you're reading it with, it
shouldn't be an issue).

Hope that helps,
Jeff
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: mosaic_doit - is it just me?
Next Topic: Renaming a variable in IDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:44:18 PDT 2025

Total time taken to generate the page: 0.00865 seconds