Geo::GDAL  2.0
Geo::GDAL::Band Class Reference

A raster band. More...

+ Inheritance diagram for Geo::GDAL::Band:
+ Collaboration diagram for Geo::GDAL::Band:

Public Member Functions

public
Geo::GDAL::RasterAttributeTable 
AttributeTable (scalar AttributeTable)
 
public list CategoryNames (array names)
 
public scalar Checksum (scalar xoff=0, scalar yoff=0, scalar xsize=undef, scalar ysize=undef)
 
public scalar ColorInterpretation (scalar color_interpretation)
 
public method ColorInterpretations ()
 
public Geo::GDAL::ColorTable ColorTable (scalar ColorTable)
 
public method ComputeBandStats (scalar samplestep=1)
 
public method ComputeRasterMinMax (scalar approx_ok=0)
 
public list ComputeStatistics (scalar approx_ok, scalar progress=undef, scalar progress_data=undef)
 
public Geo::OGR::Layer Contours (scalar DataSource, hashref LayerConstructor, scalar ContourInterval, scalar ContourBase, arrayref FixedLevels, scalar NoDataValue, scalar IDField, scalar ElevField, subref Progress, scalar ProgressData)
 
public method CreateMaskBand (array flags)
 
public scalar DataType ()
 
public method Domains ()
 
public method Fill (scalar real_part, scalar imag_part=0.0)
 
public method FillNodata (scalar mask, scalar max_search_dist, scalar smoothing_iterations, scalar options, subref progress, scalar progress_data)
 
public method FlushCache ()
 
public scalar GetBandNumber ()
 
public list GetBlockSize ()
 
public Geo::GDAL::ColorTable GetColorTable ()
 
public method GetDataset ()
 
public list GetDefaultHistogram (scalar force=1, subref progress=undef, scalar progress_data=undef)
 
public list GetHistogram (hash parameters)
 
public Geo::GDAL::Band GetMaskBand ()
 
public list GetMaskFlags ()
 
public scalar GetMaximum ()
 
public scalar GetMinimum ()
 
public Geo::GDAL::Band GetOverview (scalar index)
 
public scalar GetOverviewCount ()
 
public list GetStatistics (scalar approx_ok, scalar force)
 
public method HasArbitraryOverviews ()
 
public list MaskFlags ()
 
public scalar NoDataValue (scalar NoDataValue)
 
public scalar PackCharacter ()
 
public scalar ReadRaster (hash params)
 
public array reference ReadTile (scalar xoff=0, scalar yoff=0, scalar xsize=< width >, scalar ysize=< height >)
 
public method RegenerateOverview (Geo::GDAL::Band overview, scalar resampling, subref progress, scalar progress_data)
 
public method RegenerateOverviews (arrayref overviews, scalar resampling, subref progress, scalar progress_data)
 
public method ScaleAndOffset (scalar scale, scalar offset)
 
public method SetColorTable (scalar ColorTable)
 
public list SetDefaultHistogram (scalar min, scalar max, scalar histogram)
 
public method SetStatistics (scalar min, scalar max, scalar mean, scalar stddev)
 
public list Size ()
 
public method Unit (scalar type)
 
public method WriteRaster (hash params)
 
public method WriteTile (scalar data, scalar xoff=0, scalar yoff=0)
 
- Public Member Functions inherited from Geo::GDAL::MajorObject
public scalar Description (scalar description)
 
public method Domains ()
 
public scalar GetDescription ()
 
public hash reference GetMetadata (scalar domain="")
 
public method GetMetadataDomainList ()
 
public hash reference Metadata (hashref metadata=undef, scalar domain= '')
 
public method SetDescription (scalar NewDesc)
 
public method SetMetadata (hashref metadata, scalar domain="")
 
- Public Member Functions inherited from Geo::GDAL
public list AccessTypes ()
 
public Geo::GDAL::Dataset AutoCreateWarpedVRT (Geo::GDAL::Dataset src, Geo::OSR::SpatialReference src_srs=undef, Geo::OSR::SpatialReference dst_srs=undef, scalar ResampleAlg='NearestNeighbour', scalar maxerror=0.0)
 
public method CPLBinaryToHex ()
 
public method CPLHexToBinary ()
 
public list Child (scalar node, scalar i)
 
public list Children (scalar node)
 
public method ComputeMedianCutPCT (Geo::GDAL::Band red, Geo::GDAL::Band green, Geo::GDAL::Band blue, scalar num_colors, scalar colors, subref progress, scalar progress_data)
 
public method ComputeProximity (Geo::GDAL::Band src, Geo::GDAL::Band proximity, hashref options, subref progress, scalar progress_data)
 
public scalar DataTypeIsComplex (scalar DataType)
 
public list DataTypeValueRange (scalar DataType)
 
public list DataTypes ()
 
public method Debug ()
 
public scalar DecToDMS (scalar angle, scalar axis, scalar precision=2)
 
public scalar DecToPackedDMS (scalar dec)
 
public method DitherRGB2PCT (scalar red, scalar green, scalar blue, scalar target, scalar colors, subref progress, scalar progress_data)
 
public method EscapeString ()
 
public scalar FindFile (scalar class, scalar basename)
 
public method FinderClean ()
 
public method GOA2GetAccessToken ()
 
public method GOA2GetAuthorizationURL ()
 
public method GOA2GetRefreshToken ()
 
public scalar GetCacheMax ()
 
public scalar GetCacheUsed ()
 
public scalar GetConfigOption (scalar key, scalar default)
 
public scalar GetDataTypeSize (scalar DataType)
 
public Geo::GDAL::Driver GetDriver (scalar name)
 
public list GetDriverNames ()
 
public method GetJPEG2000StructureAsString ()
 
public Geo::GDAL::Driver IdentifyDriver (scalar path, scalar siblings)
 
public list NodeData (scalar node)
 
public scalar NodeType (scalar type)
 
public list NodeTypes ()
 
public Geo::GDAL::Dataset Open (scalar name, scalar access= 'ReadOnly')
 
public Geo::GDAL::Dataset OpenEx (scalar name, scalar open_flags=0, array reference allowed_drivers=undef, array reference open_options=undef, array reference sibling_files=undef)
 
public Geo::GDAL::Dataset OpenShared (scalar name, scalar access= 'ReadOnly')
 
public scalar PackCharacter (scalar DataType)
 
public scalar PackedDMSToDec (scalar packed)
 
public array reference ParseXMLString (scalar XML)
 
public method Polygonize (Geo::GDAL::Band src, Geo::GDAL::Band mask, Geo::OGR::Layer out, scalar PixValField, hashref options, subref progress, scalar progress_data)
 
public method PopFinderLocation ()
 
public method PushFinderLocation (scalar path)
 
public list RIOResamplingTypes ()
 
public method RasterizeLayer (Geo::GDAL::Dataset ds, arrayref bands, Geo::OGR::Layer layer, scalar transformer, scalar arg, arrayref burn_values, hashref options, subref progress, scalar progress_data)
 
public method ReprojectImage (scalar src_ds, scalar dst_ds, scalar src_wkt=undef, scalar dst_wkt=undef, scalar ResampleAlg='NearestNeighbour', scalar WarpMemoryLimit=0, scalar maxerror=0.0, subref progress, scalar progress_data)
 
public list ResamplingTypes ()
 
public scalar SerializeXMLTree (arrayref XMLTree)
 
public method SetCacheMax (scalar Bytes)
 
public method SetConfigOption (scalar key, scalar value)
 
public method SieveFilter (Geo::GDAL::Band src, Geo::GDAL::Band mask, Geo::GDAL::Band dst, scalar threshold, scalar connectedness, hashref options, subref progress, scalar progress_data)
 
public scalar VersionInfo (scalar request= 'VERSION_NUM')
 

Public Attributes

scalar XSize
 Object attribute. scalar (access as $band->{XSize})
 
scalar YSize
 Object attribute. scalar (access as $band->{YSize})
 

Detailed Description

A raster band.

Definition at line 1392 of file all.pm.

Member Function Documentation

public Geo::GDAL::RasterAttributeTable Geo::GDAL::Band::AttributeTable ( scalar  AttributeTable)
Parameters
AttributeTable[optional] A Geo::GDAL::RasterAttributeTable object.
Returns
a new Geo::GDAL::RasterAttributeTable object, whose data is contained within the band.
Code:
click to view
public list Geo::GDAL::Band::CategoryNames ( array  names)
Parameters
names[optional]
Returns
Code:
click to view
public scalar Geo::GDAL::Band::Checksum ( scalar  xoff = 0,
scalar  yoff = 0,
scalar  xsize = undef,
scalar  ysize = undef 
)

Computes a checksum from the raster or a part of it.

Parameters
xoff
yoff
xsize
ysize
Returns
the checksum.
Code:
click to view
public scalar Geo::GDAL::Band::ColorInterpretation ( scalar  color_interpretation)
Note
a.k.a. GetRasterColorInterpretation and GetColorInterpretation (get only and returns an integer), SetRasterColorInterpretation and SetColorInterpretation (set only and requires an integer)
Parameters
color_interpretation[optional] new color interpretation, one of Geo::GDAL::Band::ColorInterpretations.
Returns
color interpretation, one of Geo::GDAL::Band::ColorInterpretations.
Code:
click to view
public method Geo::GDAL::Band::ColorInterpretations ( )
Code:
click to view
public Geo::GDAL::ColorTable Geo::GDAL::Band::ColorTable ( scalar  ColorTable)

Get or set the color table of this band.

Parameters
ColorTable[optional] a Geo::GDAL::ColorTable object
Returns
a new Geo::GDAL::ColorTable object in a non-void context.
Code:
click to view
public method Geo::GDAL::Band::ComputeBandStats ( scalar  samplestep = 1)
Parameters
samplestepthe row increment in computing the statistics.
Note
Returns uncorrected sample standard deviation.

See also Geo::GDAL::Band::ComputeStatistics.

Returns
a list (mean, stddev).
Code:
click to view
public method Geo::GDAL::Band::ComputeRasterMinMax ( scalar  approx_ok = 0)
Returns
arrayref MinMax = [min, max]
Code:
click to view
public list Geo::GDAL::Band::ComputeStatistics ( scalar  approx_ok,
scalar  progress = undef,
scalar  progress_data = undef 
)
Parameters
approx_okWhether it is allowed to compute the statistics based on overviews or similar.
Note
Returns uncorrected sample standard deviation.

See also Geo::GDAL::Band::ComputeBandStats.

Returns
a list ($min, $max, $mean, $stddev).
Code:
click to view
public Geo::OGR::Layer Geo::GDAL::Band::Contours ( scalar  DataSource,
hashref  LayerConstructor,
scalar  ContourInterval,
scalar  ContourBase,
arrayref  FixedLevels,
scalar  NoDataValue,
scalar  IDField,
scalar  ElevField,
subref  Progress,
scalar  ProgressData 
)

Generate contours for this raster band. This method can also be used with named parameters.

Note
This method is a wrapper for ContourGenerate.

An example:

use Geo::GDAL;
$dem = Geo::GDAL::Open('dem.gtiff');
$contours = $dem->Band->Contours(ContourInterval => 10, ElevField => 'z');
$n = $contours->GetFeatureCount;
Parameters
DataSourcea Geo::OGR::DataSource object, default is a Memory data source
LayerConstructordata for Geo::OGR::DataSource::CreateLayer, default is {Name => 'contours'}
ContourIntervaldefault is 100
ContourBasedefault is 0
FixedLevelsa reference to a list of fixed contour levels, default is []
NoDataValuedefault is undef
IDFielddefault is '', i.e., no field (the field is created if this is given)
ElevFielddefault is '', i.e., no field (the field is created if this is given)
progress[optional] a reference to a subroutine, which will be called with parameters (number progress, string msg, progress_data)
progress_data[optional]
Returns
Code:
click to view
public method Geo::GDAL::Band::CreateMaskBand ( array  flags)
Note
May invalidate any previous mask band obtained with Geo::GDAL::Band::GetMaskBand.
Parameters
flagsone or more mask flags. The flags are Geo::GDAL::Band::MaskFlags.
Code:
click to view
public scalar Geo::GDAL::Band::DataType ( )
Returns
the data type of this band (as string, one of Geo::GDAL::DataTypes).
Code:
click to view
public method Geo::GDAL::Band::Domains ( )
Code:
click to view
public method Geo::GDAL::Band::Fill ( scalar  real_part,
scalar  imag_part = 0.0 
)

Fill the band with a constant value.

Parameters
real_partReal component of fill value.
imag_partImaginary component of fill value.
Code:
click to view
public method Geo::GDAL::Band::FillNodata ( scalar  mask,
scalar  max_search_dist,
scalar  smoothing_iterations,
scalar  options,
subref  progress,
scalar  progress_data 
)

Interpolate values for pixels in this raster. The pixels to fill should be marked in the mask band with zero.

Note
This is a wrapper for Geo::GDAL::FillNodata.
Parameters
mask[optional] a mask band indicating pixels to be interpolated (zero valued) (default is to get it with Geo::GDAL::Band::GetMaskBand).
max_search_dist[optional] the maximum number of pixels to search in all directions to find values to interpolate from (default is 10).
smoothing_iterations[optional] the number of 3x3 smoothing filter passes to run (0 or more) (default is 0).
options[optional] A reference to a hash. No options have been defined so far for this algorithm (default is {}).
progress[optional] a reference to a subroutine, which will be called with parameters (number progress, string msg, progress_data) (default is undef).
progress_data[optional] (default is undef).

Documentation for GDAL algorithms

Code:
click to view
public method Geo::GDAL::Band::FlushCache ( )

Write cached data to disk. There is usually no need to call this method.

Code:
click to view
public scalar Geo::GDAL::Band::GetBandNumber ( )
Note
a.k.a. GetBand
Returns
the number of this band.
Code:
click to view
public list Geo::GDAL::Band::GetBlockSize ( )
Returns
the size of a preferred i/o raster blocks as a list (width, height).
Code:
click to view
public Geo::GDAL::ColorTable Geo::GDAL::Band::GetColorTable ( )
Note
a.k.a. GetRasterColorTable, see also ColorTable
Returns
a color table object.
Code:
click to view
public method Geo::GDAL::Band::GetDataset ( )
Code:
click to view
public list Geo::GDAL::Band::GetDefaultHistogram ( scalar  force = 1,
subref  progress = undef,
scalar  progress_data = undef 
)
Parameters
forcetrue to force the computation
progress[optional] a reference to a subroutine, which will be called with parameters (number progress, string msg, progress_data)
progress_data[optional]
Returns
a list: ($min, $max, arrayref histogram).
Code:
click to view
public list Geo::GDAL::Band::GetHistogram ( hash  parameters)

Compute histogram from the raster.

Parameters
parametersNamed parameters:
  • Min the lower bound, default is -0.5
  • Max the upper bound, default is 255.5
  • Buckets the number of buckets in the histogram, default is 256
  • IncludeOutOfRange whether to use the first and last values in the returned list for out of range values, default is false; the bucket size is (Max-Min) / Buckets if this is false and (Max-Min) / (Buckets-2) if this is true
  • ApproxOK if histogram can be computed from overviews, default is false
  • Progress an optional progress function, the default is undef
  • ProgressData data for the progress function, the default is undef
Returns
a list which contains the count of values in each bucket
Code:
click to view
public Geo::GDAL::Band Geo::GDAL::Band::GetMaskBand ( )
Returns
the mask band associated with this band.
Code:
click to view
public list Geo::GDAL::Band::GetMaskFlags ( )
Returns
th mask flags of the mask band associated with this band. The flags are Geo::GDAL::Band::MaskFlags.
Code:
click to view
public scalar Geo::GDAL::Band::GetMaximum ( )
Note
Call Geo::GDAL::Band::ComputeStatistics before calling GetMaximum to make sure the value is computed.
Returns
statistical minimum of the band or undef if statistics are not kept or computed in scalar context. In list context returns the maximum value or a (kind of) maximum value supported by the data type and a boolean value, which indicates which is the case (true is first, false is second).
Code:
click to view
public scalar Geo::GDAL::Band::GetMinimum ( )
Note
Call Geo::GDAL::Band::ComputeStatistics before calling GetMinimum to make sure the value is computed.
Returns
statistical minimum of the band or undef if statistics are not kept or computed in scalar context. In list context returns the minimum value or a (kind of) minimum value supported by the data type and a boolean value, which indicates which is the case (true is first, false is second).
Code:
click to view
public Geo::GDAL::Band Geo::GDAL::Band::GetOverview ( scalar  index)
Parameters
index0..GetOverviewCount-1
Returns
a Geo::GDAL::Band object, which represents the internal overview band, or undef. if the index is out of bounds.
Code:
click to view
public scalar Geo::GDAL::Band::GetOverviewCount ( )
Returns
the number of overviews available of the band.
Code:
click to view
public list Geo::GDAL::Band::GetStatistics ( scalar  approx_ok,
scalar  force 
)
Parameters
approx_okWhether it is allowed to compute the statistics based on overviews or similar.
forceWhether to force scanning of the whole raster.
Note
Uses Geo::GDAL::Band::ComputeStatistics internally.
Returns
a list ($min, $max, $mean, $stddev).
Code:
click to view
public method Geo::GDAL::Band::HasArbitraryOverviews ( )
Returns
true or false.
Code:
click to view
public list Geo::GDAL::Band::MaskFlags ( )

Class method.

Returns
the list of mask flags. These are
  • AllValid: There are no invalid pixels, all mask values will be 255. When used this will normally be the only flag set.
  • PerDataset: The mask band is shared between all bands on the dataset.
  • Alpha: The mask band is actually an alpha band and may have values other than 0 and 255.
  • NoData: Indicates the mask is actually being generated from nodata values. (mutually exclusive of Alpha).
Code:
click to view
public scalar Geo::GDAL::Band::NoDataValue ( scalar  NoDataValue)
Note
a.k.a. GetNoDataValue (get only), SetNoDataValue (set only)
Parameters
NoDataValue[optional] Get or set the "no data" value.
Note
$band->NoDataValue(undef) sets the "no data" value to the Posix floating point maximum.
Returns
the "no data" value in scalar context. In list context returns the no data value or an out of range value and a boolean value, which indicates which is the case (true is first, false is second).
Code:
click to view
public scalar Geo::GDAL::Band::PackCharacter ( )
Returns
the character to use in Perl pack and unpack for the DataType of this band.
Code:
click to view
public scalar Geo::GDAL::Band::ReadRaster ( hash  params)

Read data from the band.

Parameters
paramsnamed parameters. These are
  • XOff x offset (pixel coordinates) (default is 0)
  • YOff y offset (pixel coordinates) (default is 0)
  • XSize width of the area to read (default is the width of the band)
  • YSize height of the area to read (default is the height of the band)
  • BufXSize (default is undef, i.e., the same as XSize)
  • BufYSize (default is undef, i.e., the same as YSize)
  • BufType data type of the buffer (default is the data type of the band)
  • BufPixelSpace (default is 0)
  • BufLineSpace (default is 0)
  • ResampleAlg one of Geo::GDAL::RIOResamplingTypes (default is 'NearestNeighbour'),
  • Progress reference to a progress function (default is undef)
  • ProgressData (default is undef)

If the parameters are given as a list the order is as above. Entry in GDAL docs (method RasterIO)

Returns
a buffer, open the buffer with unpack function of Perl. See Geo::GDAL::Band::PackCharacter.
Code:
click to view
public array reference Geo::GDAL::Band::ReadTile ( scalar  xoff = 0,
scalar  yoff = 0,
scalar  xsize = <width>,
scalar  ysize = <height> 
)

Usage example (print the data from a band):

print "@$_\n" for ( @{ $band->ReadTile() } );

Another usage example (process the data of a large dataset that has one band):

my($W,$H) = $dataset->Band(1)->Size();
my($xoff,$yoff,$w,$h) = (0,0,200,200);
while (1) {
. if ($xoff >= $W) {
. $xoff = 0;
. $yoff += $h;
. last if $yoff >= $H;
. }
. my $data = $dataset->Band(1)->ReadTile($xoff,$yoff,min($W-$xoff,$w),min($H-$yoff,$h));
. # add your data processing code here
. $dataset->Band(1)->WriteTile($data,$xoff,$yoff);
. $xoff += $w;
}
sub min {
. return $_[0] < $_[1] ? $_[0] : $_[1];
}
Parameters
xoff
yoff
xsize
ysize
Returns
a two-dimensional Perl array, organizes as data->[y][x], y = 0..height-1, x = 0..width-1.
Code:
click to view
public method Geo::GDAL::Band::RegenerateOverview ( Geo::GDAL::Band  overview,
scalar  resampling,
subref  progress,
scalar  progress_data 
)
Parameters
overviewa Geo::GDAL::Band object for the overview.
resampling[optional] the resampling method (one of Geo::GDAL::RIOResamplingTypes) (default is Average).
progress[optional] a reference to a subroutine, which will be called with parameters (number progress, string msg, progress_data)
progress_data[optional]
Code:
click to view
public method Geo::GDAL::Band::RegenerateOverviews ( arrayref  overviews,
scalar  resampling,
subref  progress,
scalar  progress_data 
)
Todo:
This is not yet available
Parameters
overviewsa list of Geo::GDAL::Band objects for the overviews.
resampling[optional] the resampling method (one of Geo::GDAL::RIOResamplingTypes) (default is Average).
progress[optional] a reference to a subroutine, which will be called with parameters (number progress, string msg, progress_data)
progress_data[optional]
Code:
click to view
public method Geo::GDAL::Band::ScaleAndOffset ( scalar  scale,
scalar  offset 
)

Scale and offset are used to transform raw pixel values into the units returned by GetUnits(). The conversion function is:

Units value = (raw value * scale) + offset
Returns
a list ($scale, $offset), the values are undefined if they are not set.
Since
version 1.9 of the bindings.
Code:
click to view
public method Geo::GDAL::Band::SetColorTable ( scalar  ColorTable)
Note
a.k.a. SetRasterColorTable, see also ColorTable
Parameters
ColorTableA color table object.
Code:
click to view
public list Geo::GDAL::Band::SetDefaultHistogram ( scalar  min,
scalar  max,
scalar  histogram 
)
Parameters
min
max
histogramreference to an array containing the histogram
Code:
click to view
public method Geo::GDAL::Band::SetStatistics ( scalar  min,
scalar  max,
scalar  mean,
scalar  stddev 
)

Save the statistics of the band if possible (the format can save arbitrary metadata).

Parameters
min
max
mean
stddev
Code:
click to view
public list Geo::GDAL::Band::Size ( )
Returns
the size of the band as a list (width, height).
Code:
click to view
public method Geo::GDAL::Band::Unit ( scalar  type)
Parameters
type[optional] the unit (a string).
Note
$band->Unit(undef) sets the unit value to an empty string.
Returns
the unit (a string).
Since
version 1.9 of the bindings.
Code:
click to view
public method Geo::GDAL::Band::WriteRaster ( hash  params)

Write data into the band.

Parameters
paramsnamed parameters. These are
  • XOff x offset (pixel coordinates) (default is 0)
  • YOff y offset (pixel coordinates) (default is 0)
  • XSize width of the area to write (default is the width of the band)
  • YSize height of the area to write (default is the height of the band)
  • Buf a buffer containing the data. Create the buffer with pack function of Perl. See Geo::GDAL::Band::PackCharacter.
  • BufXSize (default is undef, i.e., the same as XSize)
  • BufYSize (default is undef, i.e., the same as YSize)
  • BufType data type of the buffer (default is the data type of the band)
  • BufPixelSpace (default is 0)
  • BufLineSpace (default is 0)

If the parameters are given as a list the order is as above. Entry in GDAL docs (method RasterIO)

Code:
click to view
public method Geo::GDAL::Band::WriteTile ( scalar  data,
scalar  xoff = 0,
scalar  yoff = 0 
)
Parameters
dataA two-dimensional Perl array, organizes as data->[y][x], y = 0..height-1, x = 0..width-1.
xoff
yoff
Code:
click to view

The documentation for this class was generated from the following file: