The script below reads the sizes of the bounding boxes of features into a hash, which is indexed by the value of a field in the attribute data of the feature.
use Geo::GDAL; # information that we need: $dsname = "./"; # name of the datasource (in this case a directory) $lname = "borders"; # name of the layer $field = "country"; # name of the field whose value we need $datasource = Geo::OGR::Open($dsname); $layer = $datasource->Layer($lname); $layer->ResetReading(); while ($feature = $layer->GetNextFeature()) { my $geom = $feature->GetGeometry(); my $value = $feature->GetField($field); my $extent = $geom->GetEnvelope(); $data{$value}{width} = $extent->[1] - $extent->[0]; $data{$value}{height} = $extent->[3] - $extent->[2]; }