X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Dec 2015 02:33 PM by  anon
Sum data bands
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:19
New Member


--
10 Dec 2015 02:33 PM
    Hello all. I have a lot of imagery and I'm trying to sum the bands of each image (So I statistically see things like cloud). This is my current script: ; Start ENVI e = ENVI() ; Open a data file File = Filepath('14106_001.tif', Root_Dir = 'C:\Brett', $ Subdir = ['Images']) Raster = e.OpenRaster(File) ; Determine an output file OutFile = e.GetTemporaryFilename() ; Return a file ID fid = ENVIRasterToFID(Raster) ; Compute statistics. ENVI_File_Query, fid, DIMS=dims, NB=nb ENVI_Doit, 'ENVI_Sum_Data_Doit', $ DIMS = dims, $ FID = fid, $ POS = [0,1,2], $ COMPUTE_FLAG = [0], $ OUT_DT = 4, $ OUT_BNAME = ['Sum'], $ OUT_NAME = OutFile End I'm just trying to get it to work with one image before I tackle doing all of the images in one script but even this doesn't work and I'm not sure why. I keep getting "Array dimension must be greater than 0" but I don't understand where that error is coming from.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    10 Dec 2015 02:43 PM
    I believe the problem is with the COMPUT_FLAG keyword. You must specify a 7-element array of 1s and 0s (for 'on' or 'off') for each statistic. For example, in the ENVI Help for ENVI_SUME_DATA_BANDS, it shows the following array: COMPUTE_FLAG = [1,1,1,1,0,0,0,0] Can you try this and see if it works?

    Deleted User



    New Member


    Posts:19
    New Member


    --
    11 Dec 2015 10:50 AM
    Yes! I definitely misunderstood what COMPUTE_FLAG was asking for. For the sum of the bands I just needed [1,0,0,0,0,0,0,0]. Thank you Now I just need to figure out how to batch this process.....

    Deleted User



    New Member


    Posts:19
    New Member


    --
    11 Dec 2015 11:09 AM
    Do you have any tips on how I would generate stats using 'envi_stats_doit' on this newly created "summed band'? Would I have to export that into a file first or can I do it using the temporary filename that I just created?

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    11 Dec 2015 12:37 PM
    The result of the sum_data_bands routine is a new raster and you can calculate statistics on any raster. If you are still using the ENVI Classic API, you can use ENVI_STATS_DOIT: http://www.exelisvis.com/docs/ENVI_ST... This link also mentions the new API where you can use ENVIRasterStatisticsTask.
    You are not authorized to post a reply.