The Pixelate method converts any geometry or threshold definitions of an ROI into rasterized pixels of the given ENVIRaster.


; Launch the application
e = ENVI()
; Open the input file
file = Filepath('qb_boulder_msi', ROOT_DIR=e.Root_Dir, $
raster = e.OpenRaster(file)
view = e.GetView()
layer = view.CreateLayer(raster)
; Define a new ROI with a polygon
roi = EnviRoi(NAME='Tennis Court', COLOR='Green')
data = [[480872.7214d, 4428333.0664d], $
       [480908.2576d, 4428333.0664d], $
       [480907.5742d, 4428265.4108d], $
       [480873.3289d, 4428265.7720d], $
       [480872.7214d, 4428333.0664d]]
roi.AddGeometry, data, coord_sys=raster.SpatialRef.Coord_Sys_Str, /POLYGON
; Pixelate the polygon
roi.Pixelate, raster
; Retrieve the pixel locations
addr = roi.PixelAddresses(raster)
nPts = N_Elements(addr) / 2
; Clear the pixels
roi.ClearPixels, spatialref=raster.SpatialRef
; Add back in every other pixel
roi.AddPixels, addr[*,0:nPts-1:2], spatialref=raster.SpatialRef
; Display the region
roiLayer = layer.AddRoi(roi)


ENVIROI.Pixelate, Raster [, ERROR=variable]



The ENVIRaster reference that establishes the coordinate system reference of the ROI pixel locations.



Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

Version History

ENVI 5.1


API Version


See Also