X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 24 Jul 2012 04:55 AM by  anon
Multispectral band error RasterToFID: Raster must be a single ENVIRaster
 6 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
24 Jul 2012 04:55 AM
    While executing: file = {multispectral landsat metadata file *MTL.txt} raster = envi.OpenRaster(file) fid= ENVIRasterToFID(raster) ENVI_DOIT, 'TMCAL_DOIT', FID=fid, /USE_METADATA Gives error: Invalid pointer: )>." The result may be invalid. and while compiling says: ENVIRASTERTOFID: Raster must be a single ENVIRaster. Actually Landsat calibration is fine but it stops my script! How to fix??? Full code is here: PRO untitled2 compile_opt idl2 ; insert here MTL.txt files batchfiles = ["G:\KyprMat\!!!WorkFolder\!!!!!!!!1\163-015_20100731\L5163015_01520100731_MTL.txt", $ "G:\KyprMat\!!!WorkFolder\!!!!!!!!1\160-016_20010607\L71160016_01620010607_MTL.txt", $ "G:\KyprMat\!!!WorkFolder\!!!!!!!!1\162-015_20090907\L5162015_01520090907_MTL.txt"] e = ENVI() foreach file, batchfiles do begin raster = e.OpenRaster(file) fid_raster = ENVIRasterToFID(raster) envi_file_query, fid_raster, DIMS=dims, NB=nb, BNAMES=bnames, FNAME=fname ;path and folder name path = STRMID(file,0,STRPOS(file,'\',/REVERSE_SEARCH)) folder_name = STRMID(path,STRPOS(path,'\',/REVERSE_SEARCH),STRPOS(path,'\',/REVERSE_SEARCH)) ; band 2 full_name = path + folder_name + '_b_2_.tif' pos = [1] ENVI_DOIT, 'TMCAL_DOIT', CAL_TYPE=1, DIMS=dims, FID=fid_raster, OUT_BNAME=bnames , OUT_NAME=full_name, pos=pos, R_FID=fid_output, /USE_METADATA ; band 4 full_name = path + folder_name + '_b_4_.tif' pos = [3] ENVI_DOIT, 'TMCAL_DOIT', CAL_TYPE=1, DIMS=dims, FID=fid_raster, OUT_BNAME=bnames , OUT_NAME=full_name, pos=pos, R_FID=fid_output, /USE_METADATA ; band 5 full_name = path + folder_name + '_b_5_.tif' pos = [4] ENVI_DOIT, 'TMCAL_DOIT', CAL_TYPE=1, DIMS=dims, FID=fid_raster, OUT_BNAME=bnames , OUT_NAME=full_name, pos=pos, R_FID=fid_output, /USE_METADATA endforeach end

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    24 Jul 2012 08:48 AM
    Start using some PRINT statements when you get returned variables. For example, if you open a TM file there are actually 2 datasets contained within a metadata file - the multispectral bands and the thermal band. So you have two object references: raster = e.OpenRaster(file) help, raster RASTER OBJREF = Array[2] So you will need to pass one of the objects to get a FID for it: fid = ENVIRasterToFID(raster[0]) fid = ENVIRasterToFID(raster[1])

    Deleted User



    New Member


    Posts:
    New Member


    --
    24 Jul 2012 10:55 PM
    Thx for help, but this isnt working as it should: PRO test compile_opt idl2 batchfiles = ["G:\KyprMat\!!!WorkFolder\!!!!!!!!1\163-015_20100731\L5163015_01520100731_MTL.txt"] e = ENVI() foreach file, batchfiles do begin raster = e.OpenRaster(file) print, raster[0] help, raster[0] print, '----------------------' print, raster[1] help, raster[1] print, '----------------------' fid_raster = ENVIRasterToFID(raster[0]) print, fid_raster help, fid_raster print, '----------------------' fid_raster1 = ENVIRasterToFID(raster[1]) print, fid_raster1 help, fid_raster1 print, '----------------------' endforeach end Gives me: ENVIRASTER AUXILIARY_SPATIALREF = !NULL AUXILIARY_URI = DATA_TYPE = 'byte' INTERLEAVE = 'bsq' METADATA = NBANDS = 6 NCOLUMNS = 8931 NROWS = 8161 PYRAMID_EXISTS = 1 READ_ONLY = 1 SPATIALREF = URI = 'G:\KyprMat\!!!WorkFolder\!!!!!!!!1\163-015_20100731\L5163015_01520100731_MTL.txt' ENVIRASTER ---------------------- ENVIRASTER AUXILIARY_SPATIALREF = !NULL AUXILIARY_URI = !NULL DATA_TYPE = 'byte' INTERLEAVE = 'bsq' METADATA = NBANDS = 1 NCOLUMNS = 8931 NROWS = 8161 PYRAMID_EXISTS = 0 READ_ONLY = 1 SPATIALREF = URI = 'G:\KyprMat\!!!WorkFolder\!!!!!!!!1\163-015_20100731\L5163015_01520100731_MTL.txt' ENVIRASTER ---------------------- 248 FID_RASTER LONG = 248 ---------------------- 248 FID_RASTER1 LONG = 248 Looks like ENVIRasterToFID(raster[1]) works incorrect isnt it?

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    25 Jul 2012 10:35 AM
    I agree. ENVIRasterToFID does not appear to be returning unique FIDs for each raster object. I will report this to engineering. For now, you will need to use the ENVI Classic routines to get FIDs for files with multiple datasets (Landsat with metadata in this case).

    Deleted User



    New Member


    Posts:
    New Member


    --
    25 Jul 2012 09:06 PM
    Thanks a lot. And waiting for a fix!

    Deleted User



    New Member


    Posts:
    New Member


    --
    11 Aug 2014 07:49 AM
    Has this issue been resolved? I am trying to open multispectral NITF files with a similar code as written here to run a segment only doit, and am getting the same error (Raster must be a single ENVIRaster). When I try fid=ENVIRasterToFID(raster[0]) and fid=ENVIRasterToFID(raster[1]), I get !NULLs for the Auxiliary_spatialref and Auziliary_uri. I've tried the code on multiple different NITF files and have not been successful at properly opening any files. Any help would be greatly appreciated!

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    11 Aug 2014 09:04 AM
    The bug reports appear to show this as fixed or behaving as expected. What version of ENVI are you running? It should be at least ENVI 5.0 SP3 or ENVI 5.1. You might also contact technical support directly about this if it is still happening in these versions.
    You are not authorized to post a reply.