X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 06 Feb 2014 01:41 PM by  anon
fid of IN_MEMORY image cannot be converted to ENVIRaster
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
06 Feb 2014 01:41 PM
    I'm trying to create an ENVIRaster out of an image that has been created by envi_doit, 'class_doit' using the IN_MEMORY argument. The problem is that ENVIFidToRaster fails, printing 'Unable to create ENVIRaster', when supplied with the (valid) r_fid If the IN_MEMORY switch is not used to create the image, everything works perfectly. Is there a way to convert an IN_MEMORY image to an ENVIRaster?

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    07 Feb 2014 09:13 AM
    I ran a test in ENVI 5.1 using the sample code from CLASS_DOIT with the /in_memory keyword and it returned a classification result without error. Do you want to try the following code? ;Start ENVI e = ENVI() ; Open a data file File = Filepath('qb_boulder_msi', Root_Dir = e.Root_Dir, $ Subdir = ['data']) Raster = e.OpenRaster(File) ; Determine an output file OutFile = e.GetTemporaryFilename() ; Return a file ID fid = ENVIRasterToFID(Raster) ; Perform K-Means unsupervised classification. ENVI_File_Query, fid, DIMS=dims, NB=nb ENVI_Doit,'Class_Doit', $ FID = fid, $ DIMS = dims, $ POS = Lindgen(nb), $ METHOD = 7, $ NUM_CLASSES = 5, $ ITERATIONS = 3, $ CHANGE_THRESH = 0.9, $ /in_memory, $ R_FID = r_fid ; Pass the R_FID to an ENVIRaster object. OutRaster = ENVIFIDToRaster(r_fid) ; Display the original data and the result View = e.GetView() Layer = View.CreateLayer(Raster) Portal = View.CreatePortal()

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Feb 2014 02:11 PM
    Thank you for your help. I tried your code and it works without error. I was able to find the problem by changing the various switches that differed from your code. Apparently, ENVIFidToRaster does not like ENVI_DOIT's /INVISIBLE switch. When I remove /INVISIBLE, r_fid is converted without error.

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Feb 2014 02:37 PM
    Not using /INVISIBLE works but now the output of ENVI_DOIT is not invisible. This is okay because I'm now working directly with the r_fid (no conversion to ENVIRaster).
    You are not authorized to post a reply.