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

Home » Public Forums » archive » Re: how can i use envi in batch mode to build mask from EVFs
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: how can i use envi in batch mode to build mask from EVFs [message #52703] Mon, 26 February 2007 23:19 Go to previous message
stin.wang is currently offline  stin.wang
Messages: 15
Registered: April 2006
Junior Member
On 2月27日, 上午11时39分, "stin.w...@gmail.com" <stin.w...@gmail.com> wrote:
> On 2月27日, 上午12时58分, "David Streutker" <dstreut...@gmail.com> wrote:
>
>
>
>
>
>> On Feb 24, 7:59 pm, "stin.wang" <stin.w...@gmail.com> wrote:
>
>>> Hello everyone
>
>>> i use idl/envi to do some statistic works. first i read landsat tm
>>> into envi, calculate ndvi, and so on .
>
>>> my question is how can i use envi in batch mode to build mask form
>>> EVFs. It's certainly well know in ENVI , open a image and EVFs, click
>>> basic tool-mask-build mask. But every month i need do it again
>>> according different landsat tm image. It's really boring . I lookup in
>>> ENVI library routines for such routine. but i find only
>>> ENVI_MASK_APPLY_DOIT , which apply mask to a image. can anybody help
>>> me solve this problem?
>
>> I've never tried it, but after browsing through the help files, here's
>> the direction I would take:
>
>> 1. Open and read the EVF file(s) using the functions ENVI_EVF_OPEN,
>> ENVI_EVF_READ_RECORD, etc.
>> 2. Convert the geographical coordinates to image coordinates using
>> ENVI_CONVERT_FILE_COORDINATES.
>> 3. Convert the EVF polygons to ROIs using ENVI_CREATE_ROI and
>> ENVI_DEFINE_ROI.
>> 4. Create a mask image from the ROIs, possibly using
>> ENVI_ROI_TO_IMAGE_DOIT.
>> 5. Mask your image using ENVI_MASK_APPLY_DOIT.
>
>> Hope that helps, and good luck.
>
>> -David
>
> After my testing ,your idea is really workable.
>
> i make a roi file in envi named baodi.roi,and found the output file is
> exactly what i want.
> the following program is modified from envi help file
>
> forward_function envi_get_roi_ids
>
> pro example_envi_roi_to_image_doit
> ;
> ; First restore all the base save files.
> ;
> envi, /restore_base_save_files
> ;
> ; Initialize ENVI and send all errors
> ; and warnings to the file batch.txt
> ;
> envi_batch_init, log_file='f:\working\batch.txt'
> ;
> ; Open the input file associated with
> ; the ROIs
> ;
> envi_open_file, 'f:\working\061228_SINGLEBAND.IMG', r_fid=fid
> if (fid eq -1) then begin
> envi_batch_exit
> return
> endif
> ;
> ; Restore the ROI file and get all
> ; the available ROI ids.
> ;
> envi_restore_rois, 'f:\working\baodi.roi'
> roi_ids = envi_get_roi_ids()
> if (roi_ids[0] eq -1) then return
> ;
> ; Set the necessary variables
> ;
> out_name = 'f:\working\baodi_mask_1'
> class_values = lindgen(n_elements(roi_ids))+1
> ;
> ; Call the doit
> ;
> envi_doit, 'envi_roi_to_image_doit', $
> fid=fid, roi_ids=roi_ids, out_name=out_name, $
> class_values=class_values
> ;
> ; Exit ENVI
> ;
> envi_batch_exit
> end
> ******************************************
> ******************************************
>
> then i begin to solve my problem
> below is my working
>
> ******************************************
> forward_function envi_get_roi_ids
>
> pro make_mask
>
> compile_opt idl2
> envi,/restore_base_save_files
> envi_batch_init,log_file='f:\working\batch.log',batch_lun=ba tch_lun
>
> file=dialog_pickfile(title='choose file ..(*.img)',/read)
> printf,batch_lun,'Begin Processing at' +systime()
> envi_open_file,file,r_fid=fid
> if (fid eq -1 ) then begin
> envi_batch_exit
> return
> endif
> envi_file_query,fid,ns=ns,nl=nl,nb=nb
> dims=[-1,0,ns-1,0,nl-1]
> pos=lindgen(nb)
> ;**************************************
> ;open evfs ,the test_evf has only one layer,baodi.shp
> evf_fname='F:\test_.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, i)
> print, 'Number of nodes in Record ' + $
> strtrim(i+1,2) + ': ', n_elements(record[0,*])
>
> ;fid refer to what?the orgin evfs or the img file
> ENVI_CONVERT_FILE_COORDINATES,fid,record[0,*],record[1,*],xm ap,ymap,/
> TO_MAP
> ;ENVI_CONVERT_FILE_COORDINATES,evf_id,record[0,*],record[1,* ],
>
> roi_id = ENVI_CREATE_ROI(ns=ns, nl=nl, $
> color=4, name='evfs')
> ENVI_DEFINE_ROI, roi_id, /polygon, $
> xpts=reform(XMAP), ypts=reform(YMAP)
> roi_ids = envi_get_roi_ids()
> envi_save_rois, 'f:\working\test.roi', roi_ids
> if (roi_ids[0] eq -1) then return
> ;
> ; Set the necessary variables
> ;
> out_name = 'f:\working\baodi_mask_2'
> class_values = lindgen(n_elements(roi_ids))+1
> ;
> ; Call the doit
> ;
> envi_doit, 'envi_roi_to_image_doit', $
> fid=fid, roi_ids=roi_ids, out_name=out_name, $
> class_values=class_values
>
> endfor
>
> ;
> ; Close the EVF file
> ;
> envi_evf_close, evf_id
> ;**************************************
>
> envi_batch_exit
>
> END
>
> ;******************* ****
>
> this program doesn't work. and you have mention above
> 1 , i open evfs ,the output should be all right. the output record is
> a two dims array,one for x, and one for y,x,y is latitude and
> lontitude
> 2,i convert xy coordinate to image coordinate
> ENVI_CONVERT_FILE_COORDINATES,fid,record[0,*],record[1,*],xm ap,ymap,/
> TO_MAP
> the fid should be what? evfs or img?
> 3,convent polygon to roi
> this step i get nothing. because i use envi open output roi, this is
> nothing at all.
> 4,because wrong above ,it doesn't matter.
> 5.......
>
> can you show me what's problem with my program???
> the batch.log says
> envi error[]
> envi_roi_to_image_doit: An error has occurred during processing
> Error: "Variable is undefined:Addr." the result maybe invalid
>
> i think it caused by the wrong roi.- 隐藏被引用文字 -
>
> - 显示引用的文字 -

i make some mistakes , haha ,finaly i solve it . thanks David for you
help,WoW
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: find index
Next Topic: Re: READ issue

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

Current Time: Fri Oct 10 14:47:19 PDT 2025

Total time taken to generate the page: 1.76041 seconds