Geo::GDAL::Band Class Reference

Inherits Geo::GDAL::MajorObject, and Geo::GDAL.

Inheritance diagram for Geo::GDAL::Band:

Inheritance graph
[legend]
List of all members.

Public Object Methods

scalar GetBandNumber ()
scalar DataType ()
list Size ()
list GetBlockSize ()
scalar ColorInterpretation (scalar color_interpretation)
scalar NoDataValue (scalar NoDataValue)
 Unit (scalar type)
 ScaleAndOffset (scalar scale, scalar offset)
scalar GetMinimum ()
scalar GetMaximum ()
list ComputeStatistics (scalar approx_ok)
list GetStatistics (scalar approx_ok, scalar force)
 SetStatistics (scalar min, scalar max, scalar mean, scalar stddev)
scalar GetOverviewCount ()
Geo::GDAL::Band GetOverview (scalar band)
 HasArbitraryOverviews ()
scalar Checksum (scalar xoff=0, scalar yoff=0, scalar xsize=undef, scalar ysize=undef)
 ComputeRasterMinMax (scalar approx_ok=0)
 ComputeBandStats (scalar samplestep=1)
 Fill (scalar real_part, scalar imag_part=0.0)
 WriteTile (scalar data, scalar xoff=0, scalar yoff=0)
listref ReadTile (scalar xoff=0, scalar yoff=0, scalar xsize=< width >, scalar ysize=< height >)
 WriteRaster (scalar xoff, scalar yoff, scalar xsize, scalar ysize, scalar buf, scalar buf_xsize=undef, scalar buf_ysize=undef, scalar buf_type=undef)
scalar ReadRaster (scalar xoff, scalar yoff, scalar xsize, scalar ysize, scalar buf_xsize=undef, scalar buf_ysize=undef, scalar buf_type=undef)
list GetHistogram (hash parameters)
list GetDefaultHistogram (scalar force=1, scalar callback=undef, scalar callback_data=undef)
list SetDefaultHistogram (scalar min, scalar max, scalar histogram)
 FlushCache ()
Geo::GDAL::ColorTable ColorTable (scalar ColorTable)
Geo::GDAL::ColorTable GetColorTable ()
 SetColorTable (scalar ColorTable)
 CreateMaskBand ()
Geo::GDAL::Band GetMaskBand ()
scalar GetMaskFlags ()
list CategoryNames (list names)
scalar GetRasterCategoryNames ()
 SetRasterCategoryNames (scalar names)
Geo::GDAL::RasterAttributeTable AttributeTable (scalar AttributeTable)
Geo::GDAL::RasterAttributeTable GetDefaultRAT ()
 SetDefaultRAT (scalar AttributeTable)
Geo::OGR::Layer Contours (scalar DataSource, hashref LayerConstructor, scalar ContourInterval, scalar ContourBase, listref FixedLevels, scalar NoDataValue, scalar IDField, scalar ElevField, scalar callback, scalar callback_data)
 FillNodata (scalar mask, scalar max_search_dist=10, scalar smoothing_iterations=0, scalar options=ref_to_anon_empty_hash, scalar callback, scalar callback_data)

Public Attributes

list COLOR_INTERPRETATIONS
 XSize
 YSize

Member Function Documentation

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.

list Geo::GDAL::Band::CategoryNames ( list  names  ) 

Parameters:
names [optional]
Returns:

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.

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::COLOR_INTERPRETATIONS
Returns:
color interpretation, one of @Geo::GDAL::Band::COLOR_INTERPRETATIONS

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.

Geo::GDAL::Band::ComputeBandStats ( scalar  samplestep = 1  ) 

Parameters:
samplestep 
Returns:
arrayref Stats [mean, stddev]

Geo::GDAL::Band::ComputeRasterMinMax ( scalar  approx_ok = 0  ) 

Returns:
arrayref MinMax = [min, max]

list Geo::GDAL::Band::ComputeStatistics ( scalar  approx_ok  ) 

Parameters:
approx_ok Whether it is allowed to compute the statistics based on overviews or similar.
Returns:
a list ($min, $max, $mean, $stddev).

Geo::OGR::Layer Geo::GDAL::Band::Contours ( scalar  DataSource,
hashref  LayerConstructor,
scalar  ContourInterval,
scalar  ContourBase,
listref  FixedLevels,
scalar  NoDataValue,
scalar  IDField,
scalar  ElevField,
scalar  callback,
scalar  callback_data 
)

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:
DataSource a Geo::OGR::DataSource object, default is a Memory data source
LayerConstructor data for Geo::OGR::DataSource::CreateLayer, default is {Name => 'contours'}
ContourInterval default is 100
ContourBase default is 0
FixedLevels a reference to a list of fixed contour levels, default is []
NoDataValue default is undef
IDField default is '', i.e., no field (the field is created if this is given)
ElevField default is '', i.e., no field (the field is created if this is given)
callback [optional] a reference to a subroutine, which will be called with parameters (number progress, string msg, callback_data)
callback_data [optional]
Returns:

Geo::GDAL::Band::CreateMaskBand (  ) 

scalar Geo::GDAL::Band::DataType (  ) 

Returns:
a data type string (Byte, UInt16, Int16, UInt32, Int32, Float32, Float64, CInt16, CInt32, CFloat32, or CFloat64).

Geo::GDAL::Band::Fill ( scalar  real_part,
scalar  imag_part = 0.0 
)

Fill the band with a constant value.

Parameters:
real_part Real component of fill value.
imag_part Imaginary component of fill value.

Geo::GDAL::Band::FillNodata ( scalar  mask,
scalar  max_search_dist = 10,
scalar  smoothing_iterations = 0,
scalar  options = ref_to_anon_empty_hash,
scalar  callback,
scalar  callback_data 
)

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

Geo::GDAL::Band::FlushCache (  ) 

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

scalar Geo::GDAL::Band::GetBandNumber (  ) 

Note:
a.k.a. GetBand
Returns:
the number of this band.

list Geo::GDAL::Band::GetBlockSize (  ) 

Returns:
the size of a preferred i/o raster blocks as a list (width, height).

Geo::GDAL::ColorTable Geo::GDAL::Band::GetColorTable (  ) 

Note:
a.k.a. GetRasterColorTable, see also ColorTable
Returns:
a color table object.

list Geo::GDAL::Band::GetDefaultHistogram ( scalar  force = 1,
scalar  callback = undef,
scalar  callback_data = undef 
)

Parameters:
force true to force the computation
callback [optional] a reference to a subroutine, which will be called with parameters (number progress, string msg, callback_data)
callback_data [optional]
Returns:
a list: ($min, $max, arrayref histogram).

Geo::GDAL::RasterAttributeTable Geo::GDAL::Band::GetDefaultRAT (  ) 

Deprecated:
use Geo::GDAL::Band::AttributeTable, which makes sure the band is not destroyed before the attribute table.
Returns:
a new Geo::GDAL::RasterAttributeTable object, whose data is contained within the band.

list Geo::GDAL::Band::GetHistogram ( hash  parameters  ) 

Compute histogram from the raster.

Parameters:
parameters Named 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

Geo::GDAL::Band Geo::GDAL::Band::GetMaskBand (  ) 

scalar Geo::GDAL::Band::GetMaskFlags (  ) 

scalar Geo::GDAL::Band::GetMaximum (  ) 

Returns:
statistical minimum of the band or undef if statistics are not kept or computed.

scalar Geo::GDAL::Band::GetMinimum (  ) 

Returns:
statistical minimum of the band or undef if statistics are not kept or computed.

Geo::GDAL::Band Geo::GDAL::Band::GetOverview ( scalar  band  ) 

Parameters:
band 0..GetOverviewCount-1
Returns:
a new Geo::GDAL::Band object.

scalar Geo::GDAL::Band::GetOverviewCount (  ) 

Returns:
the number of overviews available of the band.

scalar Geo::GDAL::Band::GetRasterCategoryNames (  ) 

Note:
a.k.a. GetCategoryNames, see also CategoryNames
Returns:
names

list Geo::GDAL::Band::GetStatistics ( scalar  approx_ok,
scalar  force 
)

Parameters:
approx_ok Whether it is allowed to compute the statistics based on overviews or similar.
force Whether to force scanning of the whole raster.
Returns:
a list ($min, $max, $mean, $stddev).

Geo::GDAL::Band::HasArbitraryOverviews (  ) 

Returns:
true or false.

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:
There does not exist a good way to clear the no data value. $band->NoDataValue(undef) does not do what you want.
Returns:
the nodata value.

scalar Geo::GDAL::Band::ReadRaster ( scalar  xoff,
scalar  yoff,
scalar  xsize,
scalar  ysize,
scalar  buf_xsize = undef,
scalar  buf_ysize = undef,
scalar  buf_type = undef 
)

Parameters:
xoff 
yoff 
xsize 
ysize 
buf_xsize 
buf_ysize 
buf_type 
Returns:
the data in a binary buffer. Use the unpack function of Perl to get the data from the buffer.

listref 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.

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:
($scale, $offset)
Since:
version 1.9 of the bindings.

Geo::GDAL::Band::SetColorTable ( scalar  ColorTable  ) 

Note:
a.k.a. SetRasterColorTable, see also ColorTable
Parameters:
ColorTable A color table object.

list Geo::GDAL::Band::SetDefaultHistogram ( scalar  min,
scalar  max,
scalar  histogram 
)

Parameters:
min 
max 
histogram reference to an array containing the histogram

Geo::GDAL::Band::SetDefaultRAT ( scalar  AttributeTable  ) 

Parameters:
AttributeTable a Geo::GDAL::RasterAttributeTable object

Geo::GDAL::Band::SetRasterCategoryNames ( scalar  names  ) 

Note:
a.k.a. SetCategoryNames, see also CategoryNames
Parameters:
names 

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 

list Geo::GDAL::Band::Size (  ) 

Returns:
the size of the band as a list (width, height).

Geo::GDAL::Band::Unit ( scalar  type  ) 

Parameters:
type [optional] the unit (a string).
Returns:
the unit (a string).
Since:
version 1.9 of the bindings.

Geo::GDAL::Band::WriteRaster ( scalar  xoff,
scalar  yoff,
scalar  xsize,
scalar  ysize,
scalar  buf,
scalar  buf_xsize = undef,
scalar  buf_ysize = undef,
scalar  buf_type = undef 
)

Parameters:
xoff 
yoff 
xsize 
ysize 
buf The data to be written in a binary buffer. Use the pack function of Perl to prepare a buffer.
buf_xsize 
buf_ysize 
buf_type 

Geo::GDAL::Band::WriteTile ( scalar  data,
scalar  xoff = 0,
scalar  yoff = 0 
)

Parameters:
data A two-dimensional Perl array, organizes as data->[y][x], y = 0..height-1, x = 0..width-1.
xoff 
yoff 


Member Data Documentation

list Geo::GDAL::Band::COLOR_INTERPRETATIONS

Geo::GDAL::Band::XSize

scalar (access as $band->{XSize})

Geo::GDAL::Band::YSize

scalar (access as $band->{YSize})


The documentation for this class was generated from the following file:
Generated on 26 May 2013 for Geo::GDAL by  doxygen 1.4.7