X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Jan 2012 02:23 AM by  anon
Subseting Landsat TIFF files
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
10 Jan 2012 02:23 AM
    Hi, I'm using the following code to subset a series of Landsat thermal images with a .evf file (lake boundary). I can use the GUI in ENVI and subset the data with ZERO problem. But when using the batch processing in IDL, I get an out put that contains nothing. ========================= forward_function envi_evf_open pro SUBSET_by_EVF_batch envi, /restore_base_save_files envi_batch_init,log_file='batch.txt' out_dir='C:\Users\ghoy\Downloads\Lake_Superior\Bytho_landsat\test\out\' path_dir='C:\Users\ghoy\Downloads\Lake_Superior\Bytho_landsat\test\' ; define the image to be opened sub_files= STRMID(FILE_SEARCH('C:\Users\ghoy\Downloads\Lake_Superior\Bytho_landsat\test\L5024027_02720000502_B60.TIF'),57,28) PRINT, sub_files n=N_ELEMENTS(sub_files) PRINT, 'Number of available files:', n ;----------------------------------------------------- FOR i=0, n-1 Do begin envi_open_data_file, path_dir + sub_files(i), $ r_fid=fid, /TIFF if (fid eq -1) then begin envi_batch_exit return endif ; query the file and define the output file variables envi_file_query,fid,dims=dims,ns=ns,nl=nl,nb=nb t_fid=lonarr(nb)+fid pos=lindgen(nb) out_name= out_dir + sub_files(i) + '_sub' ;open the EVF file evf_fname='C:\Users\ghoy\Downloads\Lake_Superior\Bytho_landsat\test\Export_Output_.evf' evf_id=envi_evf_open(evf_fname) ;get the vector information envi_evf_info,evf_id,num_recs=num_recs,data_type=data_type,projection=projection,$ layer_name=layer_name ; print information about each record print, 'Number of records:',num_recs ;for i=0,num_recs-1 do begin record=envi_evf_read_record(evf_id, 0) print, 'Number of nodes in Record '+strtrim(0,2)+':',n_elements(record[0,*]) print, 'Record Info:' print, record ;endfor ; Get record info (assuming one record in EVF) record=envi_evf_read_record(evf_id,0) xMap=record[0,*] yMap=record[1,*] ; Convert record to xy pixel coordinates of the image to be subsetted envi_convert_file_coordinates,fid,xf,yf,xMap,yMap ; Prepare the subset dimensions dims[0]=-1L dims[1]=min(xf)-1 dims[2]=max(xf)-1 dims[3]=min(yf)-1 dims[4]=max(yf)-1 ;Use copyfile_doit to copy input file with new dimensions envi_doit,'cf_doit',fid=t_fid,pos=pos,dims=dims,remove=0,out_name=out_name,r_fid=r_fid Endfor ; Exit Envi ;envi_batch_exit end ==================================== Would you please take a look at this code? I can also provide you with the .evf file. Thank you, Foad,
    You are not authorized to post a reply.