Hi, I'm really confused about the coordinates in ENVI and IDL, can
somebody give me some clues? I'm trying to set up ENVI header files
for some data using ENVI_PROJ_CREATE and ENVI_MAP_INFOR_CREATE, and
output each of the data file to an standard ENVI format file with
ENVI_WRITE_ENVI_FILE. I have all the information I need: dimension
ns*nl, projection name and parameters, pixel size, and a tie point for
the UPPER LEFT CORNER of the UPPER LEFT CELL.
It works fine when I added these information directly into ENVI. I
need to process many data files, so I made an idl code as following to
batch process all the data.
Pro test
compile_opt idl2
envi, /restore_base_save_files
envi_batch_init
image = fltarr(1024, 1024)
openr, 1, 'mydata.dat'
readu, 1, image
close, 1
;polar stereographic projection
params=[6371200.0, 6371200.0,60.0000, -80.0000,0.0,0.0]
name='ps_idl'
proj=envi_proj_create(type=31,name=name,params=params)
;set the pixel size and tie point
ps=[23684.997, 23684.997]
mc=[0d,0,-12126597.0,12126840.0]
ns=1024
nl=1024
map_info=envi_map_info_create(mc=mc,ps=ps,proj=proj)
envi_write_envi_file,image,data_type=4,nb=1, $
ns=ns, nl=nl, map_info=map_info,r_fid=fid, $
out_name='test.img'
envi_batch_exit
end
The code works. But when I opened the output test.img in ENVI and
compared the map coordinates to those I got directly from ENVI, they
were off somewhat. So I googled the relevant postings here and finally
realized that because the tie point is for the upper left corner of
the upper left cell, which is the way ENVI choose for referring pixel
coordinates, but in IDL, the coordinates referring to the center of a
pixel (am I right about this?). So I thought I just need to adjust
the mc=[0d,0,-12126597.0,12126840.0] to
mc=[-0.5d,-0.5,-12126597.0,12126840.0]. However, the output test.img
are off more than the output using mc=[0d,0...]. I have no idea why
this is happening. Could somebody help me?
Many thanks,
Jenny
|