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:

  1. Copy and paste the procedure into an IDL editor window.
  2. Save the file as enviraster_tiles_foreach_example.pro.
  3. Compile and run the procedure.

PRO enviraster_tiles_foreach_example

  ; Launch the application

  e = ENVI()

 

  ; Create an ENVIRaster

  file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $

    SUBDIRECTORY = ['data'])

  raster = e.OpenRaster(file)

   

  ; Iterate through the tiles of the first band

  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:

  1. Copy and paste the procedure into an IDL editor window.
  2. Save the file as enviraster_tiles_for_with_next_example.
  3. Compile and run the procedure.

PRO enviraster_tiles_for_with_next_example

COMPILE_OPT IDL2

  ; Launch the application

  e = ENVI()

 

  ; Create an ENVIRaster

  file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $

    SUBDIRECTORY = ['data'])

  raster = e.OpenRaster(file)

 

  ; Iterate through the tiles of the first band

  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:

  1. Copy and paste the procedure into an IDL editor window.
  2. Save the file as enviraster_tiles_while_example.
  3. Compile and run the procedure.

PRO enviraster_tiles_while_example

COMPILE_OPT IDL2

  ; Launch the application

  e = ENVI()

 

  ; Create an ENVIRaster

  file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $

    SUBDIRECTORY = ['data'])

  raster = e.OpenRaster(file)

 

  ; Iterate through the tiles of the first band

  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 values are 'spatial', 'bsq' (for spatial tiling), 'spectral', 'bil', 'bip' (for spectral tiling). The default value is 'spatial'.

If set to 'spatial' or 'bsq', the iterator returns two-dimensional tiles of the form:

[range(columns dimension), range(rows dimension)]

The same spatial range is returned N times for N bands specified by the BANDS keyword.

If set to 'spectral' or 'bil', the iterator returns two-dimensional tiles of the form:

[range(columns dimension), range(bands dimension)]

In this case, a tile is returned for each row in the iterator span.

If set to 'bip', the iterator returns a transpose of the two-dimensional tiles of the form:

range(bands dimension)], [range(columns dimension)

As with 'spectral' and 'bil', a tile is returned for each row in the iterator span.

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

ENVI 5

Introduced

ENVI 5.6.2 Added BSQ, BIL, and BIP values for the MODE keyword.

API Version

4.2

See Also

ENVIRaster::CreateTileIterator, ENVIRaster::SetTile