Hi All,
I'm writing code to do batch masking on an image set. One mask is a large vector I've got it coded as .shp file but would actually prefer it to be a .evf, are those file types interchangeable with ENVIVectorMaskRaster? I'm using the .shp version because that is what was used in the online tool documentation. The other thing I would like this code to do is return non-data as numerical zero not -NaN, is there a setting or keyword with this tool that will do that. Lastly I updated my code and broke it, I've included it below, the break is on the execution of the ENVIVectorMaskRaster tool, with the error 'ENVIVECTORMASKRASTER: Mask from vectors does not contain any valid pixels for input raster'. I was able to execute this procedure through the GUI with no problem. I also tried the procedure with what I think is a similar ENVI Task, that code is included but commented out, with this alternative masker, the 'Task.execute' line failed with a similar error message. Any help or suggestions would be greatly appreciated.
compile_opt IDL2
; start the application
e=ENVI(/HEADLESS)
if e eq !null then e = envi()
;mask an image with both a vector file and a raster
;define directories
idir = 'D:\GC_09_13\'
odir = 'D:\gveg\'
filelist= LIST(idir+'36111D7_13', idir+'36111D8_13', idir+'36111C8_13', idir+'36111C7_13', $
idir+'36111B7_N_13', idir+'36111B7_S_13', idir+'36111A7_13')
foreach file, filelist do begin
raster = e.OpenRaster(file)
;get file name
img = file_basename(file)
;start Veg area of interest mask
vsa = odir + img + 'vegStudyArea'
;file test to skip this step if the file in question already exists, helpful for re-run testing
if file_test(vsa) eq 1 then GOTO, JUMP100
;restrict study area to the vegetation area of interest
;this is one large vector for the whole show.
vectorName = idir + 'entire_vegarea.shp'
vectorMask = e.OpenVector(vectorName)
; ;vector mask as a task
; vmTASK = ENVITask('VectorMaskRaster')
; vmTask.DATA_IGNORE_VALUE = 0
; vmTask.INPUT_MASK_VECTOR = vectorMask
; vmTask.INPUT_RASTER = raster
; vmTask.OUTPUT_RASTER_URI = vsa
; vmTask.Execute
;Mask with vector mask raster routine
; mask the input raster using all the records from the vector data
vMask = ENVIVectorMaskRaster(raster, vectorMask)
vMask.export, vsa, 'envi', Data_IGNORE_VALUE=0
JUMP100:
; this line of code continues on to the raster mask procedure, there's no problem with this section of code.
Laura
|