ENVI_WRITE_ENVI_FILE will not write header file [message #84397] |
Mon, 03 June 2013 17:49  |
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 #84575 is a reply to message #84397] |
Tue, 04 June 2013 10:42  |
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  |
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.
|
|
|