[Gdal-dev] Using geo::GDAL:
Ari Jolma
ari.jolma at tkk.fi
Thu Mar 16 08:37:16 EST 2006
Disclaimers first: My answer may not be useful since I've got no
experience reading GRASS datasets with GDAL, and I'm going to write
about the swig-based Perl interface to GDAL.
use gdal;
$dataset = gdal::Open('grassraster');
$band = $dataset->GetRasterBand(1);
$colortable = $band->GetRasterColorTable;
for $i (0..$colortable->GetCount-1) { # I assume, or then 1..
@color = $colortable->GetColorEntryAsRGB($i);
print "$i @color\n";
}
other general information is a bit more difficult since the swig
interface does not seem to have methods like $band->GetStatistics etc.
what we have is here (poorly documented, good docs are here:
http://www.gdal.org/classGDALRasterBand.html)
http://map.hut.fi/gdal-perl/gdal.pod.html#gdal__band
it looks like you currently have to scan through the raster with
ReadRaster method to get the categories for example
Ari
wqual kirjoitti:
> Hi list,
> I would like to write a small script in perl which should extract some
> information (like color tables, number of categories) of my GRASS raster
> file.
>
> I installed the module geo::GDAL from [1],
>
> my $data =
> Geo::GDAL::Open("/home/wqual/grassdata/spearfish60/PERMANENT/cellhd/aspect",
> GA_ReadOnly);
> use Data::Dumper;
> print Dumper($data);
>
> But everything I get is:
>
> $VAR1 = bless( do{\(my $o = 136387672)}, 'Geo::GDAL::Dataset' );
>
> Afterwards, I tried this:
> my $colors = $data->GetRasterColorTable;
> use Data::Dumper;
> print Dumper($colors);
>
> But I receive the following error message: "Can't locate object method
> "GetRasterColorTable" via package "Geo::GDAL::Dataset" at Dateiauslesen.pl
> line 36.
>
> Hmm. I just do not know how to use this module for my purpose. Any ideas?
>
>
> Best regards,
>
> Wolfgang
>
> [1] http://search.cpan.org/~sderle/Geo-GDAL-0.11/GDAL.pm
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev
--
Prof. Ari Jolma
Kartografia ja Geoinformatiikka / Cartography and Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma
More information about the Gdal-dev
mailing list