NAME
Geo::GDAL - A Perl interface to the GDAL/OGR library.
SYNOPSIS
use Geo::GDAL;
ABSTRACT
This module is a part of the Perl bindings to the GDAL library. The GDAL modules allows you to access and manipulate from Perl all geospatial data that the installed GDAL library is configured to read/write.
STATUS
This module is beta quality. As most of the names and calling conventions come directly from the underlying GDAL library they are quite stable and will continue to work like they do now. However, many things could, should, and will be made more perlish.
Generally, those methods which are documented, have been tested. If the method or constructor you are looking for is not documented, perhaps there is another way of doing what you want to do.
DESCRIPTION
The gdal module allows a geospatial programmer to use the GDAL library with the ease and comfort of Perl. Find out more about GDAL at http://www.gdal.org.
To discuss gdal, ask questions and flame/praise the authors, join gdal-dev@lists.maptools.org at http://lists.maptools.org/mailman/listinfo/gdal-dev/.
PACKAGE METHODS
Note: some arguments are optional and have a default value. This is illustrated like this:
SomeMethod(arg1, arg2 = 4);
arg1 is a required argument and an example or a variable with illustrative name is given
arg2 is optional and if left off, will get the value 4 (in this case)
- UseExceptions
-
Turned on by default.
- DontUseExceptions
- Debug
- Error
- PushErrorHandler
- PopErrorHandler
- ErrorReset
- GetLastErrorNo
- GetLastErrorType
- GetLastErrorMsg
- PushFinderLocation
- PopFinderLocation
- FinderClean
- FindFile
- SetConfigOption
- GetConfigOption
- GCPsToGeoTransform
- AllRegister
-
Done by default.
- GetCacheMax
- SetCacheMax
- GetCacheUsed
- GetDataTypeSize
- DataTypeIsComplex
- GetDataTypeName
- GetDataTypeByName
- GetColorInterpretationName
- GetPaletteInterpretationName
- DecToDMS
- PackedDMSToDec
- DecToPackedDMS
- ParseXMLString
- SerializeXMLTree
- GetDriverCount
-
$n = Geo::GDAL::GetDriverCount();
- GetDriverByName
-
$driver = Geo::GDAL::GetDriverByName('driver name');
The driver name is the $driver->{ShortName}, but that is a chicken and an egg problem!
- GetDriver
-
$driver = Geo::GDAL::GetDriver($i);
- Open
-
$dataset = Geo::GDAL::Open('filename', $access = $gdalconst::GA_ReadOnly); $access = $gdalconst::GA_ReadOnly | $gdalconst::GA_Update
- AutoCreateWarpedVRT
CLASSES
Geo::GDAL::MajorObject
Superclass of Geo::GDAL::Driver, Geo::GDAL::Dataset, and Geo::GDAL::Band
- GetDescription
- SetDescription
- GetMetadata
-
$metadata = $object->GetMetadata();
- SetMetadata
Geo::GDAL::Driver
- ShortName
-
$driver->{ShortName}
- LongName
-
$driver->{LongName}
- HelpTopic
-
$driver->{HelpTopic}
- Create
-
$dataset = $driver->Create('filename', $width, $height, $bands = 1, $type = $gdalconst::GDT_Byte, $options = []);
- CreateCopy
-
$dataset = $driver->CreateCopy('filename', $src_dataset, $strict =1, $options = []);
- Delete
Geo::GDAL::Dataset
- RasterXSize
-
$dataset->{RasterXSize}
- RasterYSize
-
$dataset->{RasterYSize}
- RasterCount
-
$dataset->{RasterCount}
- GetDriver
- GetRasterBand
-
for $i (1..$dataset->RasterCount) { $band = $dataset->GetRasterBand($i); }
- GetProjection
-
$projection = $dataset->GetProjection;
- GetProjectionRef
- SetProjection
-
$dataset->SetProjection($projection);
- GetGeoTransform
-
$transform = $dataset->GetGeoTransform();
- SetGeoTransform
-
@transform = ($minX, $dx, 0, $maxY, 0, $dy); $dataset->SetGeoTransform(\@transform);
- BuildOverviews
- GetGCPCount
-
$gcp_count = $dataset->GetGCPCount();
- GetGCPProjection
-
$gcp_projection = $dataset->GetGCPProjection();
- GetGCPs
-
An example:
my $gcps = $dataset->GetGCPs(); for (0..$#$gcps) { $x[$_] = $gcps->[$_]->{GCPX}; $y[$_] = $gcps->[$_]->{GCPY}; }
- SetGCPs
-
An example:
my @gcps = (); push @gcps,new Geo::GDAL::GCP($x1, $y1); push @gcps,new Geo::GDAL::GCP($x2, $y2); $dataset->SetGCPs(\@gcps, "some projection");
- FlushCache
- AddBand
- WriteRaster
Geo::GDAL::Band
- XSize
-
$band->{XSize}
- YSize
-
$band->{YSize}
- DataType
-
$band->{DataType}
- GetRasterColorInterpretation
- SetRasterColorInterpretation
- GetNoDataValue
-
$value = $band->GetNoDataValue;
- SetNoDataValue
-
$band->SetNoDataValue($value);
- GetMinimum
- GetMaximum
- GetOffset
- GetScale
- GetOverviewCount
- GetOverview
- Checksum
- ComputeRasterMinMax
- Fill
- ReadRaster
-
$scanline = $band->ReadRaster( 0, 0, $width, 1 ); @data = unpack("i[$width]", $scanline);
See also the example below.
- WriteRaster
-
SWITCH: for ($band->{DataType}) { if ($_ == $gdalconst::$GDT_Byte) { $type = 'C'; last SWITCH; } if ($_ == $gdalconst::$GDT_Int16) { $type = 's'; last SWITCH; } if ($_ == $gdalconst::$GDT_Int32) { $type = 'i'; last SWITCH; } $nothing = 1; } unless ($nothing) { $buf = pack($type.'['.$width*$height.']',@data); $band->WriteRaster( $xoff, $yoff, $width, $height, $buf ); } The $type chars are listed in the documentation for "pack" in man perlfunc.
- FlushCache
- GetRasterColorTable
-
$colortable = $band->GetRasterColorTable;
- SetRasterColorTable
-
$band->SetRasterColorTable($colortable);
Geo::GDAL::ColorTable
$colortable = new Geo::GDAL::ColorTable(
$palette_interpretation = $gdalconst::GPI_RGB);
- Clone
- GetPaletteInterpretation
- GetCount
- GetColorEntry
-
@color = $colortable->GetColorEntryAsRGB($i);
- GetColorEntryAsRGB
-
@color = $colortable->GetColorEntryAsRGB($i);
- SetColorEntry
-
@color = (255,0,0,255); # an example, opaque red, # and RGBA color interpretation $colortable->SetColorEntry($i, \@color);
Geo::GDAL::GCP
- GCPX
-
$gcp->{GCPX}
- GCPY
-
$gcp->{GCPY}
- GCPZ
-
$gcp->{GCPZ}
- GCPPixel
-
$gcp->{GCPPixel}
- GCPLine
-
$gcp->{GCPLine}
- Info
-
$gcp->{Info}
- Id
-
$gcp->{Id}
KNOWN BUGS
The reference counting scheme is not yet implemented. Make sure that parents are not deleted before their children! Use "my" a lot. Do not give undefined/uninitialized variables to methods.
SEE ALSO
perl(1), perlfunc(1), Geo::GDAL::Const(3pm), Geo::OSR(3pm), Geo::OGR(3pm).
http://www.gdal.org
AUTHORS
The GDAL bindings team (in alphabetical order):
ari.jolma at tkk.fi cfis at interserv.com hobu at iastate.edu kruland at ku.edu warmerdam at pobox.com
COPYRIGHT AND LICENSE
Copyright 2005-2006 by the GDAL bindings team.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.