[Gdal-dev] Geo::GDAL how to close a file?
Stephen Woodbridge
woodbri at swoodbridge.com
Thu Mar 22 22:25:56 EDT 2007
Another question is How should I close a file opened like:
$dataset = Geo::GDAL::Open('filename');
Anything I need to do to dispose of objects I have accessed?
Here is a little example of doing something like gdalinfo:
#!/usr/bin/perl -w
use strict;
use Geo::GDAL;
my $f = shift @ARGV || die "gdal-test file\n";
my $dataset = Geo::GDAL::Open($f);
print "RasterXSize=".$dataset->{RasterXSize}."\n";
print "RasterYSize=".$dataset->{RasterYSize}."\n";
print "RasterCount=".$dataset->{RasterCount}."\n";
print "GetProjection=".$dataset->GetProjection."\n";
my $driver = $dataset->GetDriver;
print "driver->ShortName=".$driver->{ShortName}."\n";
for my $i (1..$dataset->{RasterCount}) {
my $band = $dataset->GetRasterBand($i);
print " band[$i]->XSize=".$band->{XSize}."\n";
print " band[$i]->YSize=".$band->{YSize}."\n";
print " band[$i]->DataType=".$band->{DataType}."\n";
print "
GetRasterColorInterpretation=".$band->GetRasterColorInterpretation."\n";
print " GetNoDataValue=".$band->GetNoDataValue."\n";
print " GetMinimum=".$band->GetMinimum."\n";
print " GetMaximum=".$band->GetMaximum."\n";
print " GetOffset=".$band->GetOffset."\n";
print " GetScale=".$band->GetScale."\n";
print " GetOverviewCount=".$band->GetOverviewCount."\n";
print " Checksum=".$band->Checksum."\n";
print "
ComputeRasterMinMax=".join(",",@{$band->ComputeRasterMinMax})."\n";
}
More information about the Gdal-dev
mailing list