Frank Cox


Geo::ReadGRIB::PlaceIterator - Provides methods to iterate through GRIB data in geographic order and to return Geo::ReadGRIB::Place objects for each location.


This documentation refers to Geo::ReadGRIB::PlaceIterator version 1.0


    use Geo::ReadGRIB;

    $w = new Geo::ReadGRIB "grib-file";

    print $w->show,"\n";
    $plit = $w->extractLaLo(data_type, lat1, long1, lat2, long2, time);
    die $w->getError if $w->getError;

    # $plit is a Geo::ReadGRIB::PlaceIterator

    for $y ( 0 .. $plit->numLat -1 ) {
        for $x ( 0 .. $plit->numLong -1 ) {
            my $place = $plit->current;
            # $place is a Geo::ReadGRIB::Place object

            $time       = $place->thisTime;
            $latitude   = $place->lat;
            $longitude  = $place->long;
            $data_types = $place->types; # an array ref of type names
            $data = $place->data(data_type);

            # process data for $x, $y



A PlaceIterator objects let you iterate through places.

Objects of this class are returned by the extractLaLo() or extract() method of a Geo::ReadGRIB object. It contains data for one or more data types at one or more times for the area extracted. The locations are sorted first by time then latitude and then by longitude. Methods are provided for sequential access to this data.

The first() method sets the iterator index to the most northwest (lat, long) pair. The current() method returns a Place object for the current location. The next() method advances the current location one place in rows from west to east and north to south starting in the northwest corner and ending in the southeast. After the last item in the southeast corner of the extracted region, another call to next() returns undef.

The convenience methods numLat() and numLong() return the number of latitude and longitude points respectively. This is handy to, for example, provide the x, y dimensions for a GD::Image new() method.


$place = $object->current;
$y = $object->numLat;
$y = $object->numLong;
$y = $object->addData;
$y = $object->isSorted;


There are no known bugs in this module. Please report problems through

or contact Frank Cox, <> Patches are welcome.


Frank Cox, <>


2009 by Frank Cox

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.