X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 30 Jul 2009 09:54 AM by  anon
Georeferencing MODIS from lat/long data
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
30 Jul 2009 09:54 AM
    Currently I am working with an output from SeaDas that is not a standard *.L2 product.  Because of this it currently does not work with the MODIS conversion kit and EPOC.  Though I am working with the author of those scripts and we may have found a way around it I was still curious to know if you could georeference a file from lat/long data.  The *.L2 output includes a band representing latitude valudes for the image and likewise for longitude.  Can you programmically use these bands to georeference a file in ENVI+IDL?  I can georeference the file using the GUI, but I wanted to write a program to process a directory in batch mode.

    Deleted User



    New Member


    Posts:
    New Member


    --
    31 Jul 2009 10:58 AM
    Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 I solved this problem myself.  You have to build a glt file and then apply it to the file.  See my example code below   ;starts envi in batch mode (no gui)   envi, /restore_base_savee_files   envi_batch_init, log_file='batch.log'     ;gets the file name   fname = 'C:\filename.hdf'     ;***NOTE*** I know the band number of my long/lat data.  In my case it was bands   ;11 and 12 you may need to  ;change this.  If you can load the data into ENVI's GUI you   ;can  determine which bands the lat/long is located in   ;opens long data   ENVI_OPEN_DATA_FILE, fname, /hdf_sd, HDFSD_DATASET=11, $        HDF_SD_INTERLEAVE=0, R_FID=x_fid   ENVI_FILE_QUERY, x_fid, ns=ns, nl=nl, nb=nb   x_pos=lindgen(nb)   if (x_fid eq -1) then begin     envi_batch_exit     print, 'error encountered:  x_fid file invalid'     return   endif     ;opens lat data   ENVI_OPEN_DATA_FILE, fname, /hdf_sd, HDFSD_DATASET=12, $     HDF_SD_INTERLEAVE=0, R_FID=y_fid   ENVI_FILE_QUERY, y_fid, ns=ns, nl=nl, nb=nb   y_pos=lindgen(nb)   if (y_fid eq -1) then begin     envi_batch_exit     print, 'error encountered:  y_fid file invalid'     return   endif   ;opens all the bands   ENVI_OPEN_DATA_FILE, fname, /hdf_sd, HDFSD_DATASET=22,    $     HDF_SD_INTERLEAVE=0, R_FID=TSS_fid   ;opens long data   ENVI_OPEN_DATA_FILE, fname, /hdf_sd, HDFSD_DATASET=11,  $     HDF_SD_INTERLEAVE=0, R_FID=x_fid   ENVI_FILE_QUERY, x_fid, ns=ns, nl=nl, nb=nb   ;opens lat data   ENVI_OPEN_DATA_FILE, fname, /hdf_sd, HDFSD_DATASET=12,  $     HDF_SD_INTERLEAVE=0, R_FID=y_fid   ENVI_FILE_QUERY, y_fid, ns=ns, nl=nl, nb=nb     ;collects the dimensions of the file   ENVI_FILE_QUERY, TSS_fid, ns=ns, nl=nl, nb=nb, data_type=data_type   pos=lindgen(nb)   dims=[-1L,0, ns-1, 0, nl-1] ;***NOTE*** I knew the zone number of my data.  ENVI reference guide uses the statement ;’zone=fix(31.0 + lat_long[1]/6.0)’  I would not get the right zone number from that equation.  ;Not sure why but I circumvented that problem by knowing the zone of my image.   ;get lat/long data   longitude = ENVI_GET_DATA(dims=dims, FID=x_fid, pos=0)   latitude = ENVI_GET_DATA(dims=dims, FID=y_fid, pos=0)   lat_long = [latitude,longitude]   zone = 18     ;making the GLT   envi_file_query, TSS_fid, sname=sname   out_name='TSS_glt   rotation=0.0   i_proj = envi_proj_create(/geographic)   o_proj = envi_proj_create(/utm, zone=zone)   envi_glt_doit, i_proj=i_proj, o_proj=o_proj, out_name=out_name, r_fid=glt_fid,$    rotation=rotation, x_fid=x_fid, y_fid=y_fid, x_pos=0, y_pos=0   ;georeference the file   out_name='TSS_georef'   envi_doit, 'envi_georef_from_glt_doit', fid=TSS_fid, glt_fid=glt_fid, $     out_name=out_name, pos=0, subset=dims, r_fid=r_fid  
    You are not authorized to post a reply.