NAME

Image::GeoTIFF::Tiled::Iterator - A convenience class to iterate through arbitrarily-shaped raster data.

SYNOPSIS

use Image::GeoTIFF::Tiled;

my $tiff = Image::GeoTIFF::Tiled->new( $tiff_filepath );
my $iter = $tiff->get_iterator_pix( $px_min, $py_min, $px_max, $py_max );

# Dump the buffered contents
$iter->dump_buffer;

while ( defined( my $val = $iter->next ) ) {
    printf "(%.3f,%.3f): %i\n", $tiff->pix2proj(@{$iter->current_coord}), $val;
    ... # do something based on the location, value
}

DESCRIPTION

A convenience class to iterate through arbitrarily-shaped raster data. Returns some useful state information although there's room for additional features.

SUBROUTINES/METHODS

METHODS

new(\%opts)

Where %opts must have the keys boundary and buffer. Used by get_iterator_* methods.

boundary

The boundary of the buffer.

buffer

Returns the reference to the data buffer (a 2D array).

get($row,$col)

Returns the value at row $row, column $col.

rows

The number of rows in the buffer.

cols

The number of columns in the buffer.

current_row

The current row corresponding to the last value passed by next.

current_col

The current column corresponding to the last value passed by next.

current_coord

Returns the (x,y) pixel coordinate corresponding to the last value returned by next as a list. The coordinate is placed in the middle of the pixel.

next

Returns the next buffer value, or undef if there are no further values.

reset

Resets the iterator so the next() returns the first value.

adjacencies

Returns the 8 adjacent values to the current coordinate as a list, starting from the northwest and going clockwise.

dump_buffer

Pretty prints the buffer's values.

COPYRIGHT & LICENSE

Copyright 2010 Blake Willmarth.

This program is free software; you can redistribute it and/or modify it under the terms of either:

  • the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or

  • the Artistic License version 2.0.