X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 01 Mar 2017 08:04 AM by  anon
ENVIMaskRaster does not work
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:24
New Member


--
01 Mar 2017 08:04 AM
    I need to create and then apply a raster mask. Here my code: File = Filepath(inputfile, Root_Dir = root_path) raster = e.OpenRaster(File) cloudmask = (raster.GetData(BAND=0) ge 0.2 and raster.GetData(BAND=1) le 285) output = Filepath(output_file, Root_Dir = output_path) maskRaster = ENVIRaster(cloudmask, URI=output) maskRaster.Save rasterWithMask = ENVIMaskRaster(raster, MaskRaster, /INVERSE) rasterWithMask.Export, masked_raster, "TIFF" The maskRaster is created correctly and is displayed by ENVI as expected. Istead, the masked raster is displayed as if the mask had not been applied. I forgot something?

    Deleted User



    New Member


    Posts:59
    New Member


    --
    01 Mar 2017 08:31 AM
    Hi, I believe you have to set a data ignore value when exporting the raster: rasterWithMask.Export, masked_raster, "TIFF", DATA_IGNORE_VALUE=0 When you reopen and display the masked raster, you should see the masked pixels. I will plan to make this tip more visible in the ENVI documentation.

    Deleted User



    New Member


    Posts:24
    New Member


    --
    01 Mar 2017 08:47 AM
    Thak you. Now it works. using the /INVERSE ENVIMaskRaster keyword with DATA_IGNORe_VALUE = 0 is equal to set only the DATA_IGNORe_VALUE = 1 ?

    Deleted User



    New Member


    Posts:59
    New Member


    --
    01 Mar 2017 10:54 AM
    Great question. Actually the INVERSE keyword and data ignore value are unrelated in this context. The data ignore value that you choose (0, 1, 100, etc.) is just the pixel value that you are assigning to the masked pixels when exporting the masked raster to disk. They display as NoData when you view them in ENVI. When you create a binary mask file, the pixel values are 0 and 1. When you apply the mask to the input raster, you are creating a "masked raster." The "pixel state" for those pixels is set to 2 to indicate that they are masked. (See Raster Pixel State if you're interested in the details.) If you set the /INVERSE keyword on ENVIMaskRaster, the opposite pixels (specified by your mask) are then set to a pixel state of 2. So the INVERSE keyword just affects the pixel state and is not related to the data ignore value.
    You are not authorized to post a reply.