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

Home » Public Forums » archive » ENVI_WRITE_ENVI_FILE will not write header file
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
ENVI_WRITE_ENVI_FILE will not write header file [message #84397] Mon, 03 June 2013 17:49 Go to next message
Oana Coman is currently offline  Oana Coman
Messages: 27
Registered: December 2011
Junior Member
I have sat here for hours trying to figure out this seemingly simple task of writing out an envi file, but this procedure refuses to write a header file for my image.

I took all the code I wrote and just shortened it to these few lines:

startFile = 'file.img'
ENVI_OPEN_FILE, startFile, R_FID=combined, NO_REALIZE=1
if (combined eq -1) then begin
PRINTERROR,2,'Failed to open' + inTRR
return
endif
ENVI_FILE_QUERY, combined, ns=ns, nl=nl, nb=nb, data_type=data_type, descrip=descrip, bnames=bnames, dims=dims
projection = ENVI_GET_PROJECTION(FID=combined, pixel_size=ps, units=units)

combinedImage = fltarr(ns,nl,nb)
for b=0,nb-1,1 do begin
combinedImage[*,*,b] = ENVI_GET_DATA(fid=combined, dims=dims, pos=b)
endfor

out = 'out.img'
ENVI_WRITE_ENVI_FILE, combinedImage, INTERLEAVE=0, MAP_INFO=projection, OUT_NAME=out, NB=nb, NL=nl, NS=ns, OUT_DT=4, OFFSET=0, OUT_NAME=out, PIXEL_SIZE=ps

Then I basically want to resize some other input images, add them to this 'combined image', and output it back out, keeping the same projection/header information as the original combinedImage file (though I'm not even worried about doing the resizing/addition right now). I just want to output the file.

Seems simple enough. Not working though! I get no header when I output.

Then I tried to make my own header file using:
ENVI_SETUP_HEAD, FNAME=out,INTERLEAVE=0, DATA_TYPE=4, MAP_INFO=projection, NB=nb, NL=nl, NS=ns, OFFSET=0, PIXEL_SIZE=ps, units=units, /WRITE

and I get the error 'Tag name O_RPC is undefined for structure ENVI_PROJ_STRUCT.'
I have no idea what that is.

When I print my projection information, this is what I get:
{ Mars Equirectangular Default 17 3396190.0 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0 D_Unknown 0 80398784
PROJCS["Mars Equirectangular Default",GEOGCS["GCS_Unknown",DATUM["D_Unknown",SPHEROID[ "S_Unknown",3396190.0,0.0]],PRIMEM["Greenwich",0.0],UNIT[ "Degree",0.0174532925199433]],PROJECTION["Equidistant_Cylindrical "],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing ",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1 ",0.0],UNIT["Meter",1.0]]
0}
That's the projection I've been using all along to run various procedures on my images, and they've been working fine.

Does anyone have any idea why IDL is not wanting to output my header information?
Thanks guys.
Re: ENVI_WRITE_ENVI_FILE will not write header file [message #84556 is a reply to message #84397] Wed, 05 June 2013 21:09 Go to previous message
Josh Sixsmith is currently offline  Josh Sixsmith
Messages: 13
Registered: December 2012
Junior Member
It needs the whole map information structure rather than just the projection parameters, ie pixel tie points, pixel sizes etc

Use ENVI_GET_MAP_INFO rather than ENVI_GET_PROJECTION for your projection information.

Cheers
Josh
Re: ENVI_WRITE_ENVI_FILE will not write header file [message #84575 is a reply to message #84397] Tue, 04 June 2013 10:42 Go to previous message
Oana Coman is currently offline  Oana Coman
Messages: 27
Registered: December 2011
Junior Member
On Tuesday, June 4, 2013 10:29:49 AM UTC-5, Brian J. Daniel wrote:
> On Monday, June 3, 2013 8:49:08 PM UTC-4, Kat wrote:
>
>> I have sat here for hours trying to figure out this seemingly simple task of writing out an envi file, but this procedure refuses to write a header file for my image.
>
>>
>
>>
>
>>
>
>> I took all the code I wrote and just shortened it to these few lines:
>
>>
>
>>
>
>>
>
>> startFile = 'file.img'
>
>>
>
>> ENVI_OPEN_FILE, startFile, R_FID=combined, NO_REALIZE=1
>
>>
>
>> if (combined eq -1) then begin
>
>>
>
>> PRINTERROR,2,'Failed to open' + inTRR
>
>>
>
>> return
>
>>
>
>> endif
>
>>
>
>> ENVI_FILE_QUERY, combined, ns=ns, nl=nl, nb=nb, data_type=data_type, descrip=descrip, bnames=bnames, dims=dims
>
>>
>
>> projection = ENVI_GET_PROJECTION(FID=combined, pixel_size=ps, units=units)
>
>>
>
>>
>
>>
>
>> combinedImage = fltarr(ns,nl,nb)
>
>>
>
>> for b=0,nb-1,1 do begin
>
>>
>
>> combinedImage[*,*,b] = ENVI_GET_DATA(fid=combined, dims=dims, pos=b)
>
>>
>
>> endfor
>
>>
>
>>
>
>>
>
>> out = 'out.img'
>
>>
>
>> ENVI_WRITE_ENVI_FILE, combinedImage, INTERLEAVE=0, MAP_INFO=projection, OUT_NAME=out, NB=nb, NL=nl, NS=ns, OUT_DT=4, OFFSET=0, OUT_NAME=out, PIXEL_SIZE=ps
>
>>
>
>>
>
>>
>
>> Then I basically want to resize some other input images, add them to this 'combined image', and output it back out, keeping the same projection/header information as the original combinedImage file (though I'm not even worried about doing the resizing/addition right now). I just want to output the file.
>
>>
>
>>
>
>>
>
>> Seems simple enough. Not working though! I get no header when I output.
>
>>
>
>>
>
>>
>
>> Then I tried to make my own header file using:
>
>>
>
>> ENVI_SETUP_HEAD, FNAME=out,INTERLEAVE=0, DATA_TYPE=4, MAP_INFO=projection, NB=nb, NL=nl, NS=ns, OFFSET=0, PIXEL_SIZE=ps, units=units, /WRITE
>
>>
>
>>
>
>>
>
>> and I get the error 'Tag name O_RPC is undefined for structure ENVI_PROJ_STRUCT.'
>
>>
>
>> I have no idea what that is.
>
>>
>
>>
>
>>
>
>> When I print my projection information, this is what I get:
>
>>
>
>> { Mars Equirectangular Default 17 3396190.0 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
>
>>
>
>> 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
>
>>
>
>> 0 D_Unknown 0 80398784
>
>>
>
>> PROJCS["Mars Equirectangular Default",GEOGCS["GCS_Unknown",DATUM["D_Unknown",SPHEROID[ "S_Unknown",3396190.0,0.0]],PRIMEM["Greenwich",0.0],UNIT[ "Degree",0.0174532925199433]],PROJECTION["Equidistant_Cylindrical "],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing ",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1 ",0.0],UNIT["Meter",1.0]]
>
>>
>
>> 0}
>
>>
>
>> That's the projection I've been using all along to run various procedures on my images, and they've been working fine.
>
>>
>
>>
>
>>
>
>> Does anyone have any idea why IDL is not wanting to output my header information?
>
>>
>
>> Thanks guys.
>
>
>
> Do you have permissions to write where you are trying to write? The error messages (if any) are not helpful if this is the case.

Yes, I have permission. I am able to run MATH_DOIT and other procedures that output the image and its header just fine :(
Re: ENVI_WRITE_ENVI_FILE will not write header file [message #84577 is a reply to message #84397] Tue, 04 June 2013 08:29 Go to previous message
Brian Daniel is currently offline  Brian Daniel
Messages: 80
Registered: July 2009
Member
On Monday, June 3, 2013 8:49:08 PM UTC-4, Kat wrote:
> I have sat here for hours trying to figure out this seemingly simple task of writing out an envi file, but this procedure refuses to write a header file for my image.
>
>
>
> I took all the code I wrote and just shortened it to these few lines:
>
>
>
> startFile = 'file.img'
>
> ENVI_OPEN_FILE, startFile, R_FID=combined, NO_REALIZE=1
>
> if (combined eq -1) then begin
>
> PRINTERROR,2,'Failed to open' + inTRR
>
> return
>
> endif
>
> ENVI_FILE_QUERY, combined, ns=ns, nl=nl, nb=nb, data_type=data_type, descrip=descrip, bnames=bnames, dims=dims
>
> projection = ENVI_GET_PROJECTION(FID=combined, pixel_size=ps, units=units)
>
>
>
> combinedImage = fltarr(ns,nl,nb)
>
> for b=0,nb-1,1 do begin
>
> combinedImage[*,*,b] = ENVI_GET_DATA(fid=combined, dims=dims, pos=b)
>
> endfor
>
>
>
> out = 'out.img'
>
> ENVI_WRITE_ENVI_FILE, combinedImage, INTERLEAVE=0, MAP_INFO=projection, OUT_NAME=out, NB=nb, NL=nl, NS=ns, OUT_DT=4, OFFSET=0, OUT_NAME=out, PIXEL_SIZE=ps
>
>
>
> Then I basically want to resize some other input images, add them to this 'combined image', and output it back out, keeping the same projection/header information as the original combinedImage file (though I'm not even worried about doing the resizing/addition right now). I just want to output the file.
>
>
>
> Seems simple enough. Not working though! I get no header when I output.
>
>
>
> Then I tried to make my own header file using:
>
> ENVI_SETUP_HEAD, FNAME=out,INTERLEAVE=0, DATA_TYPE=4, MAP_INFO=projection, NB=nb, NL=nl, NS=ns, OFFSET=0, PIXEL_SIZE=ps, units=units, /WRITE
>
>
>
> and I get the error 'Tag name O_RPC is undefined for structure ENVI_PROJ_STRUCT.'
>
> I have no idea what that is.
>
>
>
> When I print my projection information, this is what I get:
>
> { Mars Equirectangular Default 17 3396190.0 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
>
> 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
>
> 0 D_Unknown 0 80398784
>
> PROJCS["Mars Equirectangular Default",GEOGCS["GCS_Unknown",DATUM["D_Unknown",SPHEROID[ "S_Unknown",3396190.0,0.0]],PRIMEM["Greenwich",0.0],UNIT[ "Degree",0.0174532925199433]],PROJECTION["Equidistant_Cylindrical "],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing ",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1 ",0.0],UNIT["Meter",1.0]]
>
> 0}
>
> That's the projection I've been using all along to run various procedures on my images, and they've been working fine.
>
>
>
> Does anyone have any idea why IDL is not wanting to output my header information?
>
> Thanks guys.

Do you have permissions to write where you are trying to write? The error messages (if any) are not helpful if this is the case.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: reading multiple FITS files from a directory
Next Topic: A small feature I would love to have for IDL NG

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

Current Time: Wed Oct 08 13:28:01 PDT 2025

Total time taken to generate the page: 0.76312 seconds