ENVIRasterIterator
This is a reference to an object that allows you to iterate through the raster dataset by tiles. For details on creating this reference, see ENVIRaster::CreateTileIterator.
Examples
The following examples are functionally equivalent and are provided to show the different ways in which you may use an ENVIRasterIterator.
Iterating with FOREACH
For the following example:
- Copy and paste the procedure into an IDL editor window.
- Save the file as enviraster_tiles_foreach_example.pro.
- Compile and run the procedure.
PRO enviraster_tiles_foreach_example
e = ENVI()
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
tileIterator = raster.CreateTileIterator(BANDS=0)
count = 0
FOREACH tile, tileIterator DO BEGIN
count++
PRINT, 'Tile Number:'
PRINT, count
PRINT, 'Min:'
PRINT, MIN(tile)
PRINT, 'Max:'
PRINT, MAX(tile)
PRINT, 'BAND:'
PRINT, tileIterator.CURRENT_BAND
PRINT, 'SUB_RECT:'
PRINT, tileIterator.CURRENT_SUBRECT
ENDFOREACH
END
Interating with a FOR Loop
For the following example:
- Copy and paste the procedure into an IDL editor window.
- Save the file as enviraster_tiles_for_with_next_example.
- Compile and run the procedure.
PRO enviraster_tiles_for_with_next_example
COMPILE_OPT IDL2
e = ENVI()
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
tileIterator = raster.CreateTileIterator(BANDS=0)
FOR count=1, tileIterator.NTILES DO BEGIN
tile = tileIterator.Next()
PRINT, 'Tile Number:'
PRINT, count
PRINT, 'Min:'
PRINT, MIN(tile)
PRINT, 'Max:'
PRINT, MAX(tile)
PRINT, 'BAND:'
PRINT, tileIterator.CURRENT_BAND
PRINT, 'SUB_RECT:'
PRINT, tileIterator.CURRENT_SUBRECT
ENDFOR
END
Iterating with a WHILE Loop
For the following example:
- Copy and paste the procedure into an IDL editor window.
- Save the file as enviraster_tiles_while_example.
- Compile and run the procedure.
PRO enviraster_tiles_while_example
COMPILE_OPT IDL2
e = ENVI()
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
tileIterator = raster.CreateTileIterator(BANDS=0)
count = 0
WHILE((tile = tileIterator.Next()) NE !NULL) DO BEGIN
count++
PRINT, 'Tile Number:'
PRINT, count
PRINT, 'Min:'
PRINT, MIN(tile)
PRINT, 'Max:'
PRINT, MAX(tile)
PRINT, 'BAND:'
PRINT, tileIterator.CURRENT_BAND
PRINT, 'SUB_RECT:'
PRINT, tileIterator.CURRENT_SUBRECT
ENDWHILE
END
Methods
GetData
Next
Previous
Reset
Properties
Properties marked as (Get) can be retrieved, but not set.
BANDS (Get)
An n-element array expressing the integer indices (0-based) of the bands to be included in the spectral range the iterator will traverse.
CURRENT_BAND (Get)
The band index (0-based) of the band of the iterator's current tile.
CURRENT_SUBRECT (Get)
A four-element array expressing the spatial range (in pixels) of the subrect spanned by the iterator's current tile. The array is of the form [x1, y1, x2, y2], where:
x1 = First pixel of the columns dimension
y1 = First pixel of the rows dimension
x2 = Last pixel of the columns dimension
y2 = Last pixel of the rows dimension
Pixel coordinates are zero-based.
MODE (Get)
A string describing the types of tiles that are being returned. The two values are 'spatial' and 'spectral'.
See ENVIRaster::CreateTileIterator for more details.
NTILES (Get)
The total number of tiles in the iterator.
SUB_RECT (Get)
A four-element array expressing the spatial range (in pixels) of the data as requested when the tile iterator was created. The array is of the form [x1, y1, x2, y2], where:
x1 = First pixel of the columns dimension
y1 = First pixel of the rows dimension
x2 = Last pixel of the columns dimension
y2 = Last pixel of the rows dimension
If this property was not specified when the iterator was created, this value will be the entire extent of the image.
Pixel coordinates are zero-based.
TILE_SIZE (Get)
The size of the tiles requested when the iterator was created.
Note: If MODE='spectral', the value will be returned as [columns, bands].
Version History
API Version
3.6
See Also
ENVIRaster::CreateTileIterator, ENVIRaster::SetTile