Geoinformatica  0.90
Geo::Raster Class Reference

A class for geospatial rasters. More...

+ Inheritance diagram for Geo::Raster:
+ Collaboration diagram for Geo::Raster:

Classes

class  Layer
 A subclass of Gtk2::Ex::Geo::Layer and Geo::Raster. More...
 
class  MultiBandLayer
 A subclass of Gtk2::Ex::Geo::Layer, which constains several Geo::Raster objects. More...
 

Public Member Functions

public Geo::Raster interpolate (hash params)
 Interpolate values for nodata cells. More...
 
public Geo::Raster dijkstra (array cell)
 Computes a cost-to-go raster for a given cost raster and a target cell. More...
 
public Geo::Raster colored_map ()
 Attempts to use the smallest possible number of integers for the zones in the raster. More...
 
public Geo::Raster applytempl (listref templ, scalar new_val)
 Apply a modifying template on the raster. More...
 
public Geo::Vector polygonize (hash params)
 Polygonizes the raster into a polygon OGR layer. More...
 
public Geo::Raster ca_step (array k)
 Perform a cellular automata step. More...
 
public Geo::Raster focal_sum (listref mask, array cell)
 A focal sum. More...
 
public Geo::Raster focal_mean (listref mask, array cell)
 A focal mean. More...
 
public Geo::Raster focal_variance (listref mask, array cell)
 A focal variance. More...
 
public Geo::Raster focal_count (listref mask, array cell)
 A focal count of data cells. More...
 
public Geo::Raster focal_count_of (listref mask, scalar value, array cell)
 A focal count of values. More...
 
public method focal_range ()
 
public method spread ()
 
public method spread_random ()
 
public array variogram (scalar max_lag, scalar lags)
 Computes a variogram from the raster. More...
 
public method count ()
 
public method sum ()
 
public method mean ()
 
public method variance ()
 
public Geo::Raster frame (scalar with)
 Change the borders to the given value. More...
 
public Geo::Raster convolve (listref kernel)
 Compute a convolution. More...
 
public listref line (array p, array q, scalar value)
 Get or set the cell values along a line. More...
 
public listref transect (Geo::GDAL::Geometry geom, scalar delta)
 
public listref rect (array p, array q, scalar value)
 Get or set the cells of a rectangle. More...
 
public listref circle (array center, scalar r, scalar value)
 Get or set the cells within a circle. More...
 
public void floodfill (array cell, scalar value, scalar connectivity)
 Floodfill a zone. More...
 
public Geo::Raster thin (hash opt)
 Thin lines in the raster. More...
 
public Geo::Raster borders (hash params)
 Borders between zones. More...
 
public Geo::Raster areas (scalar k)
 Marks if cell belong to an area. More...
 
public Geo::Raster connect ()
 Connects broken lines. More...
 
public Geo::Raster number_areas (scalar connectivity)
 Numbers all areas with a unique integer number, even if some areas have the same values. More...
 
public Geo::Raster transform (listref tr, scalar M, scalar N, scalar pick, scalar value)
 Transformation (of type conversion, because just a mathematical transformation) of the raster grid. More...
 
public method gdal_open ()
 
public Geo::GDAL::Dataset dataset ()
 Return a dataset object associated with the raster. More...
 
public Geo::GDAL::Band band ()
 Return a band object associated with the raster. More...
 
public Geo::Raster cache ()
 Creates a new grid from the GDAL source. More...
 
public void save (scalar filename, scalar format)
 Save libral raster into a pair of hdr and bil files. More...
 
public void print ()
 Prints the values of the raster grid into stdout. More...
 
public void dump (scalar to)
 Prints the data (but not metadata, like size or other attributes of the grid) of the raster into a file or stdout. More...
 
public void restore (scalar from)
 Reads the data (but not metadata, like size or other attributes of the grid) of the raster from a file or stdin. More...
 
public void save_as_image (scalar filename, scalar type, listref option_keys, listref option_values)
 Saves the grid as image (*.jpeg, *.png, *.tiff, *.ico or *.bmp). More...
 
public method as_string ()
 
public method bool ()
 
public method shallow_copy ()
 
public Geo::Raster neg ()
 Unary minus. Multiplies this raster with -1. More...
 
private method _typeconversion ()
 
public Geo::Raster plus (Geo::Raster second)
 Adds a raster to this raster. More...
 
public Geo::Raster minus (Geo::Raster second, scalar reversed)
 Subtracts a raster from this raster. More...
 
public Geo::Raster times (Geo::Raster second)
 Multiplies the cell values of this raster with the cell values of another raster. More...
 
public Geo::Raster over (Geo::Raster second, scalar reversed)
 Divides this raster with another raster. More...
 
public method over2 ()
 
public Geo::Raster modulo (Geo::Raster second, scalar reversed)
 Computes the modulus (remainder of division, Perl operator %) of this raster and an integer raster. More...
 
public Geo::Raster power (Geo::Raster exponent, scalar reversed)
 Computes the power (Perl operator **) of this raster an exponent raster. More...
 
public Geo::Raster add (Geo::Raster second)
 Adds another raster to this raster. More...
 
public Geo::Raster subtract (Geo::Raster second)
 Subtracts from the cell value the respective cell values of the given raster. More...
 
public Geo::Raster multiply_by (Geo::Raster second)
 Multiplies the cell values of this raster with the respective cell values of the given raster. More...
 
public Geo::Raster divide_by (Geo::Raster second)
 Divides the cell values of this raster with the respective cell values of the other raster. More...
 
public Geo::Raster modulus_with (Geo::Raster second)
 Computes the modulus of each cell value of this raster and the respective cell value of the given integer raster. More...
 
public Geo::Raster to_power_of (Geo::Raster second)
 Raises the cell values to the power of the respective cell values of the given raster. More...
 
public Geo::Raster atan2 (Geo::Raster second)
 Calculates at each cell the arc-tangent of this and the second raster. More...
 
public Geo::Raster cos ()
 Calculates the cosine at each cell. More...
 
public Geo::Raster sin ()
 Calculates the sine at each cell. More...
 
public Geo::Raster exp ()
 Calculates the exponential function at each cell. More...
 
public Geo::Raster abs ()
 Calculates the absolute value at each cell. More...
 
public Geo::Raster sqrt ()
 Calculates the square root at each cell. More...
 
public Geo::Raster round ()
 Rounds the value at each cell. More...
 
public Geo::Raster acos ()
 Calculates the arc-cosine at each cell. More...
 
public Geo::Raster atan ()
 Calculates the arc-tangent at each cell. More...
 
public Geo::Raster ceil ()
 Calculates at each cell the smallest integer not less than the value. More...
 
public Geo::Raster cosh ()
 Calculates at each cell the hyperbolic cosine of the value. More...
 
public Geo::Raster floor ()
 Calculates at each cell the largest integer less than or equal to the value. More...
 
public Geo::Raster log ()
 Calculates the logarithm at each cell. More...
 
public Geo::Raster log10 ()
 Calculates the base-10 logarithm at each cell. More...
 
public Geo::Raster sinh ()
 Calculates the hyperbolic sine at each cell. More...
 
public Geo::Raster tan ()
 Calculates the tangent at each cell. More...
 
public Geo::Raster tanh ()
 Calculates the hyperbolic tangent at each cell. More...
 
public Geo::Raster lt (Geo::Raster second, scalar reversed)
 Performs at each cell the "less than" comparison on this and the second raster. More...
 
public Geo::Raster gt (Geo::Raster second, scalar reversed)
 Performs at each cell the "greater than" comparison on this and the second raster. More...
 
public Geo::Raster le (Geo::Raster second, scalar reversed)
 Performs at each cell the "greater than or equal to" comparison on this and the second raster. More...
 
public Geo::Raster ge (Geo::Raster second, scalar reversed)
 Performs at each cell the "greater than or equal to" comparison on this and the second raster. More...
 
public Geo::Raster eq (Geo::Raster second)
 Performs at each cell the "equal to" comparison on this and the second raster. More...
 
public Geo::Raster ne (Geo::Raster second)
 Performs at each cell the "not equal to" comparison on this and the second raster. More...
 
public Geo::Raster cmp (Geo::Raster second, scalar reversed)
 Performs at each cell the numeric comparison on this and the second raster. More...
 
public Geo::Raster not ()
 Evaluate at each cell the logical not. More...
 
public Geo::Raster and (Geo::Raster second)
 Evaluate at each cell the logical and on this and the second raster. More...
 
public Geo::Raster or (Geo::Raster second)
 Evaluate at each cell the logical or on this and the second raster. More...
 
public Geo::Raster nor (scalar second)
 Evaluates at each cell the logical nor on this and the second raster. More...
 
public method fit_surface ()
 
public Geo::Raster aspect ()
 Estimate aspects from a DEM. More...
 
public Geo::Raster slope (scalar z_factor)
 Estimate the slope from a DEM. More...
 
public Geo::Raster fdg (hash params)
 Compute a flow direction raster (FDG) from a DEM. More...
 
public method many2ds ()
 
public method movecell ()
 
public method dirsum ()
 
public Geo::Raster drain_flat_areas (Geo::Raster dem, hash params)
 Resolve the flow direction for flat areas in a FDG. More...
 
public Geo::Raster drain_depressions (Geo::Raster dem)
 Scan FDG once and drain the depressions that are found. More...
 
public method outlet ()
 
public Geo::Raster ucg ()
 Compute an upslope cell raster (UCG) from a FDG. More...
 
public method upstream ()
 
public Geo::Raster raise_pits (hash params)
 Raise each pit cell to the level of its lowest neighbor in a DEM. More...
 
public method lower_peaks (hash params)
 Lower each peak cell to the level of its highest neighbor in a DEM. More...
 
public Geo::Raster depressions (scalar inc_m)
 Return depressions defined by a FDG. More...
 
public scalar fill_depressions (hash params)
 Fill the depressions in a DEM. More...
 
public scalar breach (hash params)
 Breach the depressions in a DEM. More...
 
public Geo::Raster path (array cell, Geo::Raster stop)
 Return the flow path from the given FDG cell onwards. More...
 
public Geo::Raster path_length (Geo::Raster stop, Geo::Raster op)
 Compute a path length raster from a FDG. More...
 
public Geo::Raster path_sum (Geo::Raster stop, Geo::Raster op)
 Compute a cost-to-go raster from a FDG. More...
 
public Geo::Raster upslope_count (Geo::Raster mask, scalar include_self)
 Compute the count of the upslope cells in a FDG. More...
 
public Geo::Raster upslope_sum (Geo::Raster a, scalar include_self)
 Compute the sum of the values of the upslope cells in a raster (FDG method). More...
 
public Geo::Raster kill_extra_outlets (Geo::Raster lakes, Geo::Raster uag)
 Checks and possibly correct the sanity of the flow paths in a terrain with lakes (FDG method). More...
 
public Geo::Raster catchment (Geo::Raster catchment, array cell, scalar m)
 Return the catchment area of the given cell (FDG method). More...
 
public Geo::Raster prune (Geo::Raster fdg, Geo::Raster lakes, scalar min_length, array cell)
 Delete streams that are shorter than min_length in a streams raster. More...
 
public Geo::Raster number_streams (Geo::Raster fdg, Geo::Raster lakes, array cell, scalar id)
 Number streams in a streams raster with unique id. More...
 
public Geo::Raster subcatchments (Geo::Raster fdg, Geo::Raster lakes, array cell, scalar head)
 Divide catchments into subcatchments defined by a streams raster. More...
 
public method vectorize_catchment (hashref topology, Geo::Raster streams, Geo::Raster lakes, hash params)
 Save the subcatchment structure as a vector layer (a subcatchments raster method). More...
 
public method segment ()
 
public method route (Geo::Raster dem, Geo::Raster fdg, Geo::Raster k, scalar r)
 Route water downstream (a water state raster method). More...
 
public void vectorize_streams (Geo::Raster fdg, array cell)
 Create an OGR layer from a streams raster. More...
 
public method compare_dem_derived_ws_attribs ()
 
public hashref zones (Geo::Raster zones)
 Returns the values from the raster in a hash indexed by the zones. More...
 
public hashref zonal_fct (Geo::Raster zones, scalar fct)
 Calculates a statistic of zonal values. More...
 
public hashref zonal_count (Geo::Raster zones)
 Calculates the amount of cells in each zone. More...
 
public hashref zonal_sum (Geo::Raster zones)
 Calculates the sum of this rasters cells for each zone. More...
 
public hashref zonal_min (Geo::Raster zones)
 Calculates the minimum of this rasters cells for each zone. More...
 
public hashref zonal_max (Geo::Raster zones)
 Calculates the maximum of this rasters cells for each zone. More...
 
public hashref zonal_mean (Geo::Raster zones)
 Calculates the mean of this rasters cells for each zone. More...
 
public hashref zonal_variance (Geo::Raster zones)
 Calculates the variance of this rasters cells for each zone. More...
 
public method grow_zones ()
 
public method dl_load_flags ()
 
public method AUTOLOAD ()
 
public method from_piddle ()
 
private method _new_grid ()
 
private method _interpret_datatype ()
 
public Geo::Raster new ()
 Create a new raster. More...
 
public method height ()
 
public method width ()
 
public method DESTROY ()
 
private method _with_decimal_point ()
 
public method world ()
 
public method overlayable (Geo::Raster other)
 Test if two rasters are overlayable. More...
 
public method copy_bounding_box_to ()
 
public method flip_horizontal ()
 
public method flip_vertical ()
 
public boolean cell_in (array cell)
 Whether a cell is in this raster. More...
 
public boolean point_in (array point)
 Whether a point is in the bounding box of this raster. More...
 
public method g2w ()
 
public method w2g ()
 
public method ga2wa ()
 
public method wa2ga ()
 
public method mask (Geo::Raster mask)
 Set or remove the mask. More...
 
public void set (array cell, scalar value)
 Set the value of a cell. More...
 
public method get ()
 
public method cell ()
 
public method point ()
 
public Geo::Raster data ()
 Return a raster indicating data and nodata cells. More...
 
public method schema ()
 
public method has_field ()
 
public method table ()
 
private method _type_name ()
 
public list value_range (hash params)
 Returns the minimum and maximum values of the raster. More...
 
private method _attributes ()
 
private method _datatype ()
 
public method datatype ()
 
public method data_type ()
 
public method size ()
 
public method cell_size ()
 
public method nodata_value ()
 
public Geo::Raster min (scalar param)
 
public Geo::Raster max (scalar param)
 
public Geo::Raster random ()
 Return a random part of values of the values of this raster. More...
 
public Geo::Raster cross (Geo::Raster b)
 Cross product of rasters. More...
 
public Geo::Raster if (Geo::Raster b, Geo::Raster c, Geo::Raster d)
 If...then statement construct for rasters. More...
 
public Geo::Raster bufferzone (scalar z, scalar w)
 Creates buffer zones around cells having the given value. More...
 
public Geo::Raster distances ()
 Computes and stores into nodata cells the distance (in world units) to the nearest data cell. More...
 
public Geo::Raster directions ()
 Computes and stores into nodata cells the direction to the nearest data cell into nodata cells. More...
 
public Geo::Raster clip (scalar i1, scalar j1, scalar i2, scalar j2)
 Clips a part of the raster according to a given rectangle or the real world boundaries of a given raster. More...
 
public void assign (Geo::Raster src)
 Assigns the values from an another raster to this. More...
 
public void clip_to (Geo::Raster like)
 Creates a raster like the given raster and assigns to that raster values from this raster. More...
 
public listref array ()
 Creates a list of the rasters values. More...
 
public listref histogram (scalar bins)
 Calculates the histogram values for the given bins. More...
 
public hashref contents ()
 Returns the histogram of an integer raster in a hash. More...
 
public Geo::Raster function (scalar fct)
 Evaluates a function and assigns the result to cell. More...
 
public Geo::Raster map (map)
 Reclassify an integer raster. More...
 
public hashref neighbors ()
 Compute a neighborhood hash for an integer raster. More...
 

Static Public Member Functions

static public boolean exists (scalar filename)
 Checks if save with the same filename would overwrite an existing file. More...
 
static public log_base (scalar base, scalar value)
 Calculates the logarithm with a desired base. More...
 

Static Public Attributes

static scalar INTEGER_GRID
 
static scalar REAL_GRID
 
static hash EXPORT_TAGS
 
static scalar AUTOLOAD
 
static hash dispatch
 

Detailed Description

A class for geospatial rasters.

Import tags:

  • logics Imports (overrides) not, and, and or

NAME

Geo::Raster - Perl extension for geospatial rasters

USAGE

DESCRIPTION

SEE ALSO

Geo::GDAL

DOCUMENTATION

The documentation of Geo::Raster is included into the source code in doxygen format. The documentation can be generated in HTML, LaTeX, and other formats using the doxygen executable and the perl doxygen filter.

1) http://www.stack.nl/~dimitri/doxygen 2) http://search.cpan.org/~jordan/Doxygen-Filter-Perl/ 3) http://ajolma.net/

AUTHOR

Ari Jolma, ari.jolma at gmail.com

COPYRIGHT AND LICENSE

Copyright (C) 1999- by Ari Jolma

This library is free software; you can redistribute it and/or modify it according to the Artistic License 2.0.

Definition at line 9 of file Algorithms.pm.

Member Function Documentation

private method Geo::Raster::_attributes ( )

Undocumented Method

Code:
click to view
private method Geo::Raster::_datatype ( )

Undocumented Method

Code:
click to view
private method Geo::Raster::_interpret_datatype ( )

Undocumented Method

Code:
click to view
private method Geo::Raster::_new_grid ( )

Undocumented Method

Code:
click to view
private method Geo::Raster::_type_name ( )

Undocumented Method

Code:
click to view
private method Geo::Raster::_typeconversion ( )

Undocumented Method

Code:
click to view
private method Geo::Raster::_with_decimal_point ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::abs ( )

Calculates the absolute value at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::acos ( )

Calculates the arc-cosine at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::add ( Geo::Raster  second)

Adds another raster to this raster.

Example of addition

$a += $b;

is the same as

$a->add($b);
Parameters
[in]secondA raster to add.
Code:
click to view
public Geo::Raster Geo::Raster::and ( Geo::Raster  second)

Evaluate at each cell the logical and on this and the second raster.

The truth table of logical and:

thissecondresult
falsefalsefalse
falsetruefalse
truefalsefalse
truetruetrue

If either cell has nodata (undefined) value, the result is undefined.

Parameters
[in]secondA raster.
Returns
a new raster. In void context changes this raster.
Note
Defined only for integer rasters.
Code:
click to view
public Geo::Raster Geo::Raster::applytempl ( listref  templ,
scalar  new_val 
)

Apply a modifying template on the raster.

The "apply template" method is a generic method which is, e.g., used in the thinning algorithm.

$a->applytempl(\@templ, $new_val);
Parameters
[in]templThe structuring template (or mask) to use A structuring template is an integer array [0..8] where 0 and 1 mean a binary value and -1 is don't care. The array is the 3x3 neighborhood:
0 1 2
3 4 5
6 7 8

The cell 4 is the center of the template. If the template matches a cell's neighborhood, the cell will get the given new value after all cells are tested.

Parameters
[in]new_val(optional). New value to give to the center cell if the template rules match the cell and its 8 neighbours. If not given, then 1 is used to inform about match success.
Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::areas ( scalar  k)

Marks if cell belong to an area.

Parameters
[in]k(optional). A cell is part of an area if there are at least k consecutive nonzero cells as neighbors and the cell has also a nonzero value. By default the value is 3, in which case the smallest area is 2*2 cells.
Returns
a new raster. In void context changes this raster.
Note
The grid has to have as datatype integer.
Code:
click to view
public listref Geo::Raster::array ( )

Creates a list of the rasters values.

Example of making an array of data in a raster

$aref = $a->array;

where $aref is a reference to a list of references to arrays of cells and values:

[[i0, j0, val0], [i1, j1, val1], [i2, j2, val2], ...].

Returns
a reference to a list.
Code:
click to view
public method Geo::Raster::as_string ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::aspect ( )

Estimate aspects from a DEM.

The aspect is computed from a 9-term quadratic polynomial fitted independently on each cell of the DEM. The aspect is stored in radians increasing clockwise starting from zero in north. For flat cells the aspect is undefined, denoted with the value -1.

Returns
an aspect raster. In void context converts the DEM.
Code:
click to view
public void Geo::Raster::assign ( Geo::Raster  src)

Assigns the values from an another raster to this.

The values are looked up simply based on the center point of cell.

Example of assigning

$dest->assign($src);
Parameters
[in]srcSource raster from where the values looked up.
Code:
click to view
public Geo::Raster Geo::Raster::atan ( )

Calculates the arc-tangent at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::atan2 ( Geo::Raster  second)

Calculates at each cell the arc-tangent of this and the second raster.

Parameters
[in]secondA raster.
Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::GDAL::Band Geo::Raster::band ( )

Return a band object associated with the raster.

Returns
the band from the underlying GDAL dataset that is used, or, in the case of pure libral raster, create a GDAL memory dataset and return the (only) band of it.
Code:
click to view
public method Geo::Raster::bool ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::borders ( hash  params)

Borders between zones.

This method returns a binary raster, where the borders have the value of 1.

Parameters
[in]paramsNamed parameters:
  • method => string (optional). Either simple or recursive. Default is recursive.
Returns
a new raster. In void context changes this raster.
Code:
click to view
public scalar Geo::Raster::breach ( hash  params)

Breach the depressions in a DEM.

Breaching is a depression removal method, which lowers the elevation of cells, which form a dam. Breaching is tried at the lowest cell on the rim of the depression which has the steepest descent away from the depression (if there are more than one lowest cells) and the steepest descent into the depression (if there are more than one lowest cells with identical slope out)

The breaching algorithm implemented here is close to but not the same as in Martz and Garbrecht (1998). The biggest difference is that the depression cells are not raised in this implementation.

Parameters
[in]paramsNamed parameters:
  • limit (optional) Maximum amount of cells (width of the dam) to be breached. Default is to not limit the breaching ($limit == 0).
  • iterative=>boolean (optional) Whether to run the breach algorithm iteratively until a pitless and flatless FDG is obtained from the DEM using the D8 method or there is no progress in the iteration. In an iteration step a FDG is first computed from the DEM using the D8 method. Then the flat areas are removed from the FDG using first the multiple pour point method and then the one pour point method. The breaching algorithm is then run once (one scan of the whole raster) on the DEM using this FDG. If the flatless FDG that is computed from this changed DEM is also pitless or there is no progress in the iteration, then the iteration stops. If iterative is true, the DEM is changed and a FDG is returned. Default is true.
  • FDG=>raster (optional unless iterative is false) The FDG for the breaching algorithm. If FDG is given it must not contain flat areas. The algorithm is run only once, i.e., one scan of the FDG is performed. Default is undefined.
  • quiet=>boolean (optional) Whether to not to report the progressing of the iteration.
Returns
a DEM from which some depressions are removed (if the context is non-void and iterative is false), nothing (if FDG is given), or a pitless and flatless FDG.
Exceptions
-FDG is not given but iterative is false.
See Also
Martz, L.W. and Garbrecht, J. 1998. The treatment of flat areas and depressions in automated drainage analysis of raster digital elevation models. Hydrol. Process. 12, 843-855
Code:
click to view
public Geo::Raster Geo::Raster::bufferzone ( scalar  z,
scalar  w 
)

Creates buffer zones around cells having the given value.

Creates (or converts a raster to) a binary raster, where all cells within distance w of a cell (measured as pixels from cell center to cell center) having the value z will have value of 1, all other cells will have values of 0.

Parameters
[in]zDenotes cell values for which the bufferzone is computed.
[in]wWidth of the bufferzone.
Note
Defined only for integer rasters.
Code:
click to view
public Geo::Raster Geo::Raster::ca_step ( array  k)

Perform a cellular automata step.

Parameters
[in]kArray defining the cellular automaton defining the values with which the cell neighbor and the cell is multiplied. The indexes of the array for the neighbors are:
8 1 2
7 0 3
6 5 4

The new value for the cell is a k weighted sum of the neighborhood cell values.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::cache ( )

Creates a new grid from the GDAL source.

  • Uses the world and cell_size of the GDAL raster.
  • Otherwise works as above.
Returns
Geo::Raster.
Code:
click to view
public Geo::Raster Geo::Raster::catchment ( Geo::Raster  catchment,
array  cell,
scalar  m 
)

Return the catchment area of the given cell (FDG method).

Parameters
[in,out]catchment(optional) The raster in which to return the catchment of the given cell.
[in]cellThe cell.
[in]m(optional). Number used to mark the cells belonging to the catchment. Default is 1.
Returns
Depending on the context returns the catchment raster or a list containing the catchment raster and the number of cells in the catchment.
Code:
click to view
public Geo::Raster Geo::Raster::ceil ( )

Calculates at each cell the smallest integer not less than the value.

Returns
a new integer raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::cell ( )

Undocumented Method

Code:
click to view
public boolean Geo::Raster::cell_in ( array  cell)

Whether a cell is in this raster.

Parameters
[in]cellThe cell.
Returns
boolean value.
Code:
click to view
public method Geo::Raster::cell_size ( )

Undocumented Method

Code:
click to view
public listref Geo::Raster::circle ( array  center,
scalar  r,
scalar  value 
)

Get or set the cells within a circle.

Parameters
[in]centerThe center cell of the circle.
[in]rThe radius of the circle.
[in]value(optional) The value for the cells within the circle.
Returns
the values of the cells within the circle if value is not given. The returned value is a reference to an anonymous array of the form: (@cell, value, @cell, value, ...).
Code:
click to view
public Geo::Raster Geo::Raster::clip ( scalar  i1,
scalar  j1,
scalar  i2,
scalar  j2 
)

Clips a part of the raster according to a given rectangle or the real world boundaries of a given raster.

Example of clipping a raster:

$g2 = $g1->clip($i1, $j1, $i2, $j2);

Example of clipping a raster:

$g2 = $g1->clip($g3);

The example clips from $g1 a piece which is overlayable with $g3. If there is no lvalue, $g1 is clipped.

Parameters
[in]i1Upper left corners i-coordinate of the rectangle to clip.
[in]j1Upper left corners j-coordinate of the rectangle to clip.
[in]i2Bottom right corners i-coordinate of the rectangle to clip.
[in]j2Bottom right corners j-coordinate of the rectangle to clip.
[in]area_to_clipA Geo::Raster, which defines the area to clip.
Returns
If a return value is wanted, then the method returns a new raster with size defined by the parameters.
Code:
click to view
public void Geo::Raster::clip_to ( Geo::Raster  like)

Creates a raster like the given raster and assigns to that raster values from this raster.

Parameters
[in]likeRaster that defines the window for the new raster.
Returns
a new raster. In void context copies to this raster and discards the reference to a GDAL raster.
Code:
click to view
public Geo::Raster Geo::Raster::cmp ( Geo::Raster  second,
scalar  reversed 
)

Performs at each cell the numeric comparison on this and the second raster.

Example:

$c = $a <=> $b;

is the same as

$c = $a->cmp($b);
Parameters
[in]secondA raster to compare against.
[in]reversed(optional) Whether to perform this <=> second computation instead of second <=> this. When operator '<=>' is used, this value is automatically set by Perl when appropriate.
Returns
a new integer raster, which is -1 where this raster is smaller than the second, 0 where they are equal, and 1 where the second is larger. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::colored_map ( )

Attempts to use the smallest possible number of integers for the zones in the raster.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::compare_dem_derived_ws_attribs ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::connect ( )

Connects broken lines.

If two 8-neighbor opposite cells (1-5, 2-6, etc) of a cell are the same and the cell is zero, then the value of this cell is set to the same value.

Examples of connection:

0 1 00 1 0
0 0 0=> 0 1 0
0 1 00 1 0
1 0 11 0 1
0 0 0=> 0 1 0
0 0 10 0 1
Returns
a new raster. In void context changes this raster.
Note
The grid has to have as datatype integer.
Code:
click to view
public hashref Geo::Raster::contents ( )

Returns the histogram of an integer raster in a hash.

Returns
a reference to a hash with cell values as keys and cellcounts as values.
Code:
click to view
public Geo::Raster Geo::Raster::convolve ( listref  kernel)

Compute a convolution.

Parameters
[in]kernelThe convolution kernel is a list of lists, i.e., a 2D array that determines the focal area over which convolution is calculated. The table is read from left to right, top to down, and its center element is the cell for which the value is computed.
Returns
a new raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::copy_bounding_box_to ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::cos ( )

Calculates the cosine at each cell.

Returns
a new raster. In void context changes this raster.
Note
The resulting raster will always have as datatype real.
Code:
click to view
public Geo::Raster Geo::Raster::cosh ( )

Calculates at each cell the hyperbolic cosine of the value.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::count ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::cross ( Geo::Raster  b)

Cross product of rasters.

Creates a new Geo::Raster whose values represent distinct combinations of values of the two operand rasters. May be used as lvalue or in-place. The operand rasters must be integer rasters and the rasters must be overlayable.

$c = $a->cross($b);
$a->cross($b);

If a has values A = a(1), ..., a(n) (a(i) < a(j) if i < j) and b has values B = b(1), ..., b(m) (b(i) < b(j) if i < j) then c will have max n * m distinct values. The values in c are i(b) + i(a)*n + 1, where i(a) is the index of the value of a in array A minus 1 and i(b) is the index of the value of b in array B minus 1. c will be nodata if either a or b is nodata.

Parameters
[in]bA reference to an another Geo::Raster object.
Returns
A new raster if requested.
Code:
click to view
public Geo::Raster Geo::Raster::data ( )

Return a raster indicating data and nodata cells.

Returns
a raster, which has 1 in the cells that have values and 0 in nodata cells. In void context changes this raster.
Code:
click to view
public method Geo::Raster::data_type ( )

Undocumented Method

Code:
click to view
public Geo::GDAL::Dataset Geo::Raster::dataset ( )

Return a dataset object associated with the raster.

Returns
the underlying GDAL dataset or, in the case of pure libral raster, create a GDAL memory dataset and return it.
Code:
click to view
public method Geo::Raster::datatype ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::depressions ( scalar  inc_m)

Return depressions defined by a FDG.

Parameters
[in]inc_m(optional) A boolean value indicating whether each depression is marked with a unique integer. Default is false.
Returns
Depressions raster.
Code:
click to view
public method Geo::Raster::DESTROY ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::dijkstra ( array  cell)

Computes a cost-to-go raster for a given cost raster and a target cell.

When this method is applied to a cost raster, the method computes the cost to travel to the target cell from each cell in the raster. If the cost at a cell is less than one, the cell cannot be a part of the optimal route to the target.

Parameters
[in]cellThe target cell.
Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::directions ( )

Computes and stores into nodata cells the direction to the nearest data cell into nodata cells.

Directions are given in radians and direction zero is to the direction of x-axis, Pi/2 is to the direction of y-axis.

Returns
If a return value is wanted, then the method returns a new raster, with values only in this rasters nodata cells, having the direction to the nearest data cell.
Code:
click to view
public method Geo::Raster::dirsum ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::distances ( )

Computes and stores into nodata cells the distance (in world units) to the nearest data cell.

Returns
If a return value is wanted, then the method returns a new raster with values only in this rasters nodata cells having the distance to the nearest data cell.
Code:
click to view
public Geo::Raster Geo::Raster::divide_by ( Geo::Raster  second)

Divides the cell values of this raster with the respective cell values of the other raster.

Example:

$a /= $b;

is the same as

$a->divide_by($b);
Parameters
[in]secondA raster.
Code:
click to view
public method Geo::Raster::dl_load_flags ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::drain_depressions ( Geo::Raster  dem)

Scan FDG once and drain the depressions that are found.

This method scans the given FDG once and drains all depressions that are found in the FDG by reversing the flowpath from the lowest pour point of the depression to the pit cell. The DEM remains unchanged.

Parameters
[in]demThe DEM. The DEM is not changed in the method.
Returns
In a void context the method changes this FDG, otherwise the method returns a new FDG.
Code:
click to view
public Geo::Raster Geo::Raster::drain_flat_areas ( Geo::Raster  dem,
hash  params 
)

Resolve the flow direction for flat areas in a FDG.

The method uses either "one pour point" (short "o") or "multiple pour points" (short "m") technique for resolving the drainage of flat area cells of a FDG.

In the one pour point technique (the default) all cells on the flat area are drained to one pour point cell. The pour point cell is selected either from the border of the flat area or just outside the flat area depending whether the outside cell is not higher than the inside cell. If the pour point is on the border it is converted into a pit cell. Thus this technique is guaranteed to produce a flatless FDG but it may increase the number of pits.

In the multiple pour points approach all flat cells are iteratively drained to any non-higher neighbor whose drainage is resolved. Thus this technique is not guaranteed to produce a flatless FDG.

Parameters
[in]demThe DEM.
[in]paramsNamed parameters:
  • method=>string (optional) Either "one pour point" (short "o") or "multiple pour points" (short "m"). Default is one pour point.
  • quiet=>boolean (optional) Whether to report the result (number of cells or areas drained).
Exceptions
-No DEM supplied
-Unsupported method
Returns
In void context the method changes this flow direction raster, otherwise the method returns a new FDG.
Code:
click to view
public void Geo::Raster::dump ( scalar  to)

Prints the data (but not metadata, like size or other attributes of the grid) of the raster into a file or stdout.

Parameters
[in]to(optional). Filename or a filehandle.
Exceptions
Thegiven filename is not valid, or the file does not open with writing permissions.
Code:
click to view
public Geo::Raster Geo::Raster::eq ( Geo::Raster  second)

Performs at each cell the "equal to" comparison on this and the second raster.

Example:

$c = $a == $b;

is the same as

$c = $a->eq($b);
Parameters
[in]secondA raster to compare against.
Returns
a new integer raster, which is 0 where this raster is not equal ot the second, and 1 where they are equal. In void context changes this raster.
Code:
click to view
public static boolean Geo::Raster::exists ( scalar  filename)
static

Checks if save with the same filename would overwrite an existing file.

Parameters
[in]filenameName of file without the file type extension.
Code:
click to view
public Geo::Raster Geo::Raster::exp ( )

Calculates the exponential function at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::fdg ( hash  params)

Compute a flow direction raster (FDG) from a DEM.

Parameters
[in]paramsA hash of named parameters:
  • method=>string (optional). The method for computing the FDG. Currently supported methods are 'D8' and 'Rho8' and 'many'. D8 selects the neighbor with steepest descent. Rho8 selects randomly, using the descent as a weight, a lower cell. In the 'many' method all lower cells are coded with the 8 bits of a byte. The directions are from 1 (up) to 8 (up left)
    : 8 1 2
    7 X 3
    6 5 4<br Flat cells (no lower neighbors) are marked -1. Pit cells (all neighbor cells are higher) are marked with 0. The default is D8.
  • drain_all=>boolean (optional). Whether to use iteration to produce a FDG with drainage resolved for all cell. The iteration algorithm first applies the drain_flat_areas method using the option 'multiple pour points', then the same method with option 'one pour point'. Next the drainage of all depressions is iteratively resolved using the drain_depressions method. The default is false.
  • quiet=>boolean (optional). Whether to report the result (number of cells or areas drained).
Exceptions
-Unsupported method
-No progress in the iteration
Returns
a FDG. In void context converts the DEM.
Code:
click to view
public scalar Geo::Raster::fill_depressions ( hash  params)

Fill the depressions in a DEM.

The depressions in the DEM are filled up to the lowest cell just outside the depression. The depressions are obtained from a FDG.

Parameters
[in]paramsNamed parameters:
  • iterative=>boolean (optional) Whether to run the depression filling algorithm iteratively until a pitless and flatless FDG is obtained from the DEM using the D8 method. In an iteration step a FDG is first computed from the DEM using the D8 method. Then the flat areas are removed from the FDG using first the multiple pour point method and then the one pour point method. The depression removing algorithm is then run once (one scan of the whole raster) on the DEM using this FDG. If the flatless FDG that is computed from this changed DEM is also pitless, then the iteration stops. If iterative is true, the DEM is changed and a pitless and flatless FDG is returned. Default is true.
  • FDG=>raster (optional unless iterative is false) The FDG for the depression filling algorithm. If FDG is given, the depression filling algorithm is run only once, i.e., one scan of the FDG is performed. Default is undefined.
  • quiet=>boolean (optional) Whether to report the progressing of the iteration.
Exceptions
-FDG is not given but iterative is false.
-There is no progress in the iteration.
Returns
a DEM from which some depressions are removed (if the context is non-void and iterative is false), the number of filled depressions (if FDG is given), or a pitless and flatless FDG.
Code:
click to view
public method Geo::Raster::fit_surface ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::flip_horizontal ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::flip_vertical ( )

Undocumented Method

Code:
click to view
public void Geo::Raster::floodfill ( array  cell,
scalar  value,
scalar  connectivity 
)

Floodfill a zone.

Parameters
[in]cellA cell identifying the zone.
[in]valueNew value for the zone.
[in]connectivity(optional). Connectivity between cells, either 4 or 8. Default is 8.
Code:
click to view
public Geo::Raster Geo::Raster::floor ( )

Calculates at each cell the largest integer less than or equal to the value.

Returns
a new integer raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::focal_count ( listref  mask,
array  cell 
)

A focal count of data cells.

Parameters
[in]maskThe focal area defined as a 2D anonymous integer array. The width and height of the array must be 2d+1, where d is the max horizontal and vertical distance from the central cell.
[in]cell(optional) The cell for which the focal count is computed. If not given, the focal count is computed for the whole raster.
Returns
the focal count, either as a single number or as a new raster. If no cell is given and executed in void context, changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::focal_count_of ( listref  mask,
scalar  value,
array  cell 
)

A focal count of values.

Parameters
[in]maskThe focal area defined as a 2D anonymous integer array. The width and height of the array must be 2d+1, where d is the max horizontal and vertical distance from the central cell.
[in]valueThe value whose count in the focal area is to be computed.
[in]cell(optional) The cell for which the focal count of values is computed. If not given, the focal count_of is computed for the whole raster.
Returns
the focal count of values, either as a single number or as a new raster. If no cell is given and executed in void context, changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::focal_mean ( listref  mask,
array  cell 
)

A focal mean.

Parameters
[in]maskThe focal area defined as a 2D anonymous integer array. The width and height of the array must be 2d+1, where d is the max horizontal and vertical distance from the central cell.
[in]cell(optional) The cell for which the focal mean is computed. If not given, the focal mean is computed for the whole raster.
Returns
the focal mean, either as a single number or as a new raster. If no cell is given and executed in void context, changes this raster.
Code:
click to view
public method Geo::Raster::focal_range ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::focal_sum ( listref  mask,
array  cell 
)

A focal sum.

Parameters
[in]maskThe focal area defined as a 2D anonymous integer array. The width and height of the array must be 2d+1, where d is the max horizontal and vertical distance from the central cell.
[in]cell(optional) The cell for which the focal sum is computed. If not given, the focal sum is computed for the whole raster.
Returns
the focal sum, either as a single number or as a new raster. If no cell is given and executed in void context, changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::focal_variance ( listref  mask,
array  cell 
)

A focal variance.

Parameters
[in]maskThe focal area defined as a 2D anonymous integer array. The width and height of the array must be 2d+1, where d is the max horizontal and vertical distance from the central cell.
[in]cell(optional) The cell for which the focal variance is computed. If not given, the focal variance is computed for the whole raster.
Returns
the focal variance, either as a single number or as a new raster. If no cell is given and executed in void context, changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::frame ( scalar  with)

Change the borders to the given value.

Parameters
[in]withA value that is given to the border cells.
Returns
a new raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::from_piddle ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::function ( scalar  fct)

Evaluates a function and assigns the result to cell.

An example, which fills a raster using an arbitrary function of x and y:

$a->function('2*$x+3*$y');

The function 2x+3y is evaluated at each cell and the result is assigned to the cell.

Parameters
[in]fctA string, which defines function of x, y, z, i, j, etc. z is the current value in the cell and x, y, i, and j are coordinates.
Returns
a new raster. In a void context changes this raster.
Code:
click to view
public method Geo::Raster::g2w ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::ga2wa ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::gdal_open ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::ge ( Geo::Raster  second,
scalar  reversed 
)

Performs at each cell the "greater than or equal to" comparison on this and the second raster.

Example:

$c = $a >= $b;

is the same as

$c = $a->ge($b);
Parameters
[in]secondA raster to compare against.
[in]reversed(optional) Whether to perform this >= second computation instead of second >= this. When operator '>=' is used, this value is automatically set by Perl when appropriate.
Returns
a new integer raster, which is 0 where this raster is less than the second, and 1 where it is greater than the second. In void context changes this raster.
Code:
click to view
public method Geo::Raster::get ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::grow_zones ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::gt ( Geo::Raster  second,
scalar  reversed 
)

Performs at each cell the "greater than" comparison on this and the second raster.

Example:

$c = $a > $b;

is the same as

$c = $a->gt($b);
Parameters
[in]secondA raster to compare against.
[in]reversed(optional) Whether to perform this > second computation instead of second > this. When operator '>' is used, this value is automatically set by Perl when appropriate.
Returns
a new integer raster, which is 0 where this raster is less than or equal to the second, and 1 where it is greater than the second. In void context changes this raster.
Code:
click to view
public method Geo::Raster::has_field ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::height ( )

Undocumented Method

Code:
click to view
public listref Geo::Raster::histogram ( scalar  bins)

Calculates the histogram values for the given bins.

Parameters
[in]binsReference to an array having the border values for the bins.
[in]bins(optional) Amount of bins (disjoint categories). If not given 20 is used as bins amount. There is no "best" number of bins, and different bin sizes can reveal different features of the data.
Returns
Reference to an array having amount of cells falling to each bin.

Example of calculating a histogram:

$histogram = $gd->histogram(\@bins);

Example of calculating a histogram, where all values plotted in to 10 equal sized intervals:

$histogram = $gd->histogram(10);
Code:
click to view
public Geo::Raster Geo::Raster::if ( Geo::Raster  b,
Geo::Raster  c,
Geo::Raster  d 
)

If...then statement construct for rasters.

Parameters
[in]bRaster, whose values are used as boolean values.
[in]cValue raster, reference to a hash, or value.
[in]d(optional) Value raster, reference to a hash, or value.
Returns
a raster whose values are the results of the if statement. In void context changes the values of this raster.

Example of usage:

$a->if($b, $c);

where $a and $b are rasters and $c can be a raster or a scalar. The effect of this subroutine is:

for all cells k: if (b[k]) then a[k]=c[k]

If a return value is requested:

$d = $a->if($b, $c);
for all cells k: if (b[k]) then d[k]=c[k] else d[k]=a[k]
  • If $c is a reference to a hash of key=>value pairs, where key is an integer and value is a number, then
    for all cells k and keys key: if (b[k]==key) then a[k]=c[key]

Example of usage:

$a->if($b, $c, $d);

where $a and $b are rasters and $c and $d can be a rasters or values. The effect of this subroutine is:

for all cells k: if (b[k]) then a[k]=c[k] else a[k]=d[k]

If a return value is requested:

$e = $a->if($b, $c, $d);
for all cells k: if (b[k]) then e[k]=c[k] else e[k]=d[k]
  • If $c and $d are references to hashes of key=>value pairs, where key is an integer and value is a number, then
    for all cells k and keys key: if (b[k]==key) then a[k]=c[key] else a[k]=d[key]
Code:
click to view
public Geo::Raster Geo::Raster::interpolate ( hash  params)

Interpolate values for nodata cells.

Parameters
[in]paramsNamed parameters:
  • method => string. At moment only 'nearest neighbor' is supported.
Returns
a new raster. In void context changes this raster.
Exceptions
Aunsupported method is specified.
Todo:
Add more interpolation methods.
Code:
click to view
public Geo::Raster Geo::Raster::kill_extra_outlets ( Geo::Raster  lakes,
Geo::Raster  uag 
)

Checks and possibly correct the sanity of the flow paths in a terrain with lakes (FDG method).

The FDG is modified so that each lake has only one outlet. The lakes raster is typically a reclassified land cover raster.

Parameters
[in]lakesan integer raster of the lakes in the terrain (each lake may have its own non-zero id)
[in]uag(optional) Upslope area raster. Computed using the upslope_count method unless given.
Returns
In void context changes this flow direction raster, otherwise returns a new FDG.
Code:
click to view
public Geo::Raster Geo::Raster::le ( Geo::Raster  second,
scalar  reversed 
)

Performs at each cell the "greater than or equal to" comparison on this and the second raster.

Example:

$c = $a <= $b;

is the same as

$c = $a->le($b);
Parameters
[in]secondA raster to compare against.
[in]reversed(optional) Whether to perform this <= second computation instead of second <= this. When operator '<=' is used, this value is automatically set by Perl when appropriate.
Returns
a new integer raster, which is 0 where this raster is greater than the second, and 1 where it is less than or equal to the second. In void context changes this raster.
Code:
click to view
public listref Geo::Raster::line ( array  p,
array  q,
scalar  value 
)

Get or set the cell values along a line.

Parameters
[in]pThe first cell of the line.
[in]qThe last cell of the line.
[in]value(optional) The value for the cells along the line.
Returns
the values of the cells along the line if value is not given. The returned value is a reference to an anonymous array of the form: (@cell, value, @cell, value, ...).
Code:
click to view
public Geo::Raster Geo::Raster::log ( )

Calculates the logarithm at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::log10 ( )

Calculates the base-10 logarithm at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public static Geo::Raster::log_base ( scalar  base,
scalar  value 
)
static

Calculates the logarithm with a desired base.

Parameters
baseDesired logarithm base.
valueValue for which the logarithm is calculated.
Returns
the result of the logarithm function.
Code:
click to view
public method Geo::Raster::lower_peaks ( hash  params)

Lower each peak cell to the level of its highest neighbor in a DEM.

Parameters
[in]paramsNamed parameters:
  • z_limit=>number (optional) A threshold value for how much higher than its neighbors a cell may be before it is lowered. Default is 0.
  • quiet=>boolean (optional) Whether the method should report the number of cells raised.
Returns
In void context the method changes this DEM, otherwise the method returns a new DEM.
Code:
click to view
public Geo::Raster Geo::Raster::lt ( Geo::Raster  second,
scalar  reversed 
)

Performs at each cell the "less than" comparison on this and the second raster.

Example:

$c = $a < $b;

is the same as

$c = $a->lt($b);
Parameters
[in]secondA raster to compare against.
[in]reversed(optional) Whether to perform this < second computation instead of second < this. When operator '<' is used, this value is automatically set by Perl when appropriate.
Returns
a new integer raster, which is 0 where this raster is greater than or equal to the second, and 1 where it is less than the second. In void context changes this raster.
Code:
click to view
public method Geo::Raster::many2ds ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::map ( map  )

Reclassify an integer raster.

Parameters
[in]mapThis is a reference to a hash of (key=>value) mappings. The key may be '*' (denoting a default value) or an integer. The value is a new value for the cell. If the value is a real number (i.e., contains '.') the result will be a real valued raster.
[in]mapThis is a reference to a list of of pairs of mappings. The key may be '*' (denoting a default value), number, or a reference to a list denoting a value range: [min_value, max_value]. The value is a new value for the cell. If the value is a real number (i.e., contains '.') the result is a real valued raster.
Returns
a new raster. In void context changes this raster.

Example of mapping values

$b = $a->map(\%map);

or

$a->map(\%map);

or, using an anonymous hash created on the fly,

$a->map({1=>5,2=>3});

Maps cell values (keys in the map) in raster a to respective values in map. Works only for integer rasters.

Code:
click to view
public method Geo::Raster::mask ( Geo::Raster  mask)

Set or remove the mask.

Parameters
[in]mask(optional). If mask is undef, the method removes the current mask.
Code:
click to view
public Geo::Raster Geo::Raster::max ( scalar  param)

Depending on the parameter either set each cell to the maximum of its value and the parameter value or to the maximum of its value and the value of the respective cell in the parameter raster.

Parameters
[in]paramNumber to compare with the raster cell values.
[in]paramA raster, whose values are compared the values of this raster.
Returns
A new raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::mean ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::min ( scalar  param)

Depending on the parameter either set each cell to the minimum of its value and the parameter value or to the minimum of its value and the value of the respective cell in the parameter raster.

Parameters
[in]paramNumber to compare with the raster cell values.
[in]paramA raster, whose values are compared the values of this raster.
Returns
A new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::minus ( Geo::Raster  second,
scalar  reversed 
)

Subtracts a raster from this raster.

Example:

$c = $b - $a;

is the same as

$c = $a->minus($b, 1);
Parameters
[in]secondA raster to be subtracted.
[in]reversed(optional) Whether to perform value - raster computation instead of raster - value. When operator '-' is used, this value is automatically set by Perl when appropriate.
Returns
the resulting raster.
Code:
click to view
public Geo::Raster Geo::Raster::modulo ( Geo::Raster  second,
scalar  reversed 
)

Computes the modulus (remainder of division, Perl operator %) of this raster and an integer raster.

Example:

$c = $a % $b;

is the same as

$c = $a->modulo($b);
Parameters
[in]secondAn integer raster.
[in]reversed(optional) Whether to perform second % raster computation instead of raster % second. When operator '' is used, this value is automatically set by Perl when appropriate.
Note
This raster must be an integer raster.
Returns
the resulting raster.
Code:
click to view
public Geo::Raster Geo::Raster::modulus_with ( Geo::Raster  second)

Computes the modulus of each cell value of this raster and the respective cell value of the given integer raster.

Example:

$a %= $b;

is the same as

$a->modulus_with($b);
Parameters
[in]secondAn integer raster.
Note
Defined only for integer rasters.
Code:
click to view
public method Geo::Raster::movecell ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::multiply_by ( Geo::Raster  second)

Multiplies the cell values of this raster with the respective cell values of the given raster.

Example of multiplication

$a *= $b;

is the same as

$a->multiply_by($b);
Parameters
[in]secondA raster.
Code:
click to view
public Geo::Raster Geo::Raster::ne ( Geo::Raster  second)

Performs at each cell the "not equal to" comparison on this and the second raster.

Example:

$c = $a != $b;

is the same as

$c = $a->ne($b);
Parameters
[in]secondA raster to compare against.
Returns
a new integer raster, which is 0 where this raster is equal to the second, and 1 where they are not equal. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::neg ( )

Unary minus. Multiplies this raster with -1.

Returns
A negated (multiplied by -1) raster.
Code:
click to view
public hashref Geo::Raster::neighbors ( )

Compute a neighborhood hash for an integer raster.

Returns
A reference to a hash of pairs (a=>b), where a is each cell value and b is a reference to a list of values that are found within the neighborhood of cells having the value a.
Code:
click to view
public Geo::Raster Geo::Raster::new ( )

Create a new raster.

Parameters
[in]paramsNamed parameters:
  • datatype The data type for the new raster. Either "real" or "integer". Default is integer.
  • copy A raster to be copied into the new raster.
  • like A raster to be used as a model for the new raster (no data is copied).
  • filename Name of a raster file. GDAL is used for opening the file.
  • access Access mode for GDAL. Either 'ReadOnly' or 'Update'. Default is 'ReadOnly'.
  • band integer (optional) Which band to read from the file. Default is 1.
  • load boolean (optional) Whether to convert the GDAL raster into a libral raster. Default is false.
  • rows Height of the new raster.
  • columns Width of the new raster.
  • world Named parameters suitable to define the real world boundaries. Used only if rows and columns are also given. Possible parameters include:
    • cell_size
    • minx
    • miny
    • maxx
    • maxy
[in]datatype(optional) The datatype for the new raster, either "integer" or "real". Default is integer.
[in]rowsHeight of the new raster.
[in]columnsWidth of the new raster.
[in]filenameName of a raster file that is recognized by GDAL.
Returns
a new raster.

Example of using only a filename:

$raster = Geo::Raster->new("data/dem.bil");
Note
The new raster is only an interface to a raster accessed by GDAL. To load data from GDAL to memory use the method Geo::Raster::IO::cache.

Example of creating a new floating point raster:

$raster = Geo::Raster->new('real', 100, 100);

Example of creating a new integer raster:

$raster = Geo::Raster->new(100, 100);
Exceptions
Thecells of the raster in a file are not squares.
Theorientation of the raster in a file is not strictly north up.
Todo:
Take GDAL into account in copying.
Code:
click to view
public method Geo::Raster::nodata_value ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::nor ( scalar  second)

Evaluates at each cell the logical nor on this and the second raster.

The truth table of logical nor:

thissecondresult
falsefalsetrue
falsetruefalse
truefalsefalse
truetruefalse

If either cell has nodata (undefined) value, the result is undefined.

Parameters
[in]secondA raster, whose cell values are used to calculate the logical inverse of disjunction.
Returns
a new raster. In void context changes this raster.
Note
Defined only for integer rasters.
Code:
click to view
public Geo::Raster Geo::Raster::not ( )

Evaluate at each cell the logical not.

Returns
a new raster. In void context changes this raster.
Note
Defined only for integer rasters.
Code:
click to view
public Geo::Raster Geo::Raster::number_areas ( scalar  connectivity)

Numbers all areas with a unique integer number, even if some areas have the same values.

Parameters
[in]connectivity(optional). Connectivity between cells as a number:4 or 8. If connectivity is not given then 8-connectivity is used.
Returns
a new raster. In void context changes this raster.
Note
The grid has to have as datatype integer.
Code:
click to view
public Geo::Raster Geo::Raster::number_streams ( Geo::Raster  fdg,
Geo::Raster  lakes,
array  cell,
scalar  id 
)

Number streams in a streams raster with unique id.

Parameters
[in]fdgFlow direction raster.
[in]lakes(optional) Lakes raster.
[in]cell(optional) The root cell (a catchment outlet) from which the method begins to treat the streams. If not given then all stream trees are treated.
[in]id(optional) Number for the first found stream, the next streams will get higher unique numbers. Default is 1.
Returns
In void context changes this streams raster, otherwise returns a new streams raster.
Code:
click to view
public Geo::Raster Geo::Raster::or ( Geo::Raster  second)

Evaluate at each cell the logical or on this and the second raster.

The truth table of logical or:

thissecondresult
falsefalsefalse
falsetruetrue
truefalsetrue
truetruetrue

If either cell has nodata (undefined) value, the result is undefined.

Parameters
[in]secondA raster.
Returns
a new raster. In void context changes this raster.
Note
Defined only for integer rasters.
Code:
click to view
public method Geo::Raster::outlet ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::over ( Geo::Raster  second,
scalar  reversed 
)

Divides this raster with another raster.

Example:

$c = $a / $b;

is the same as

$c = $a->over($b);

The effect of raster division is

for all cells: c[cell] = a[cell]/b[cell]
Parameters
[in]secondA raster
[in]reversed(optional) Whether to perform value / raster computation instead of raster / value. When operator '/' is used, this value is automatically set by Perl when appropriate.
Returns
the resulting raster.
Code:
click to view
public method Geo::Raster::over2 ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::overlayable ( Geo::Raster  other)

Test if two rasters are overlayable.

Code:
click to view
public Geo::Raster Geo::Raster::path ( array  cell,
Geo::Raster  stop 
)

Return the flow path from the given FDG cell onwards.

The end of the path is where flow direction is not specified, where it goes out of the raster, or where the stop raster has a positive value.

Parameters
[in]cellThe origin of the path.
[in]stop(optional) Raster denoting end cells for paths.
Returns
raster, where the path cells have the value 1 and otherwise no data value. In void context changes the FDG.
Code:
click to view
public Geo::Raster Geo::Raster::path_length ( Geo::Raster  stop,
Geo::Raster  op 
)

Compute a path length raster from a FDG.

The path is assumed to go from a center point of a cell to another center point. The length is not recorded if op is nodata. The length is calculated in the raster units. A path ends at the border of the FDG, at a FDG cell with undefined direction, or at a cell in the stop raster with positive value.

Parameters
[in]stop(optional) Raster denoting end cells for paths.
[in]op(optional) Raster denoting cells which are included in the length computation.
Returns
a flow path length raster. In void context changes the FDG.
Code:
click to view
public Geo::Raster Geo::Raster::path_sum ( Geo::Raster  stop,
Geo::Raster  op 
)

Compute a cost-to-go raster from a FDG.

This FDG method returns a raster, where the value of each cell is the weighted (with length) sum along the path from that cell to the end of the path. The path is assumed to go from a center point of a cell to another center point. The length is not recorded if op is nodata. The length is calculated in the raster units.

Parameters
[in]stop(optional) Raster denoting end cells for paths.
[in]opWeights (cost) for the summing.
Returns
a cost-to-go raster. In void context changes the FDG.
Code:
click to view
public Geo::Raster Geo::Raster::plus ( Geo::Raster  second)

Adds a raster to this raster.

Example:

$c = $a + $b;

is the same as

$c = $a->plus($b);
Parameters
[in]secondA raster.
Returns
the resulting raster.
Code:
click to view
public method Geo::Raster::point ( )

Undocumented Method

Code:
click to view
public boolean Geo::Raster::point_in ( array  point)

Whether a point is in the bounding box of this raster.

Parameters
[in]pointThe point (x, y)
Returns
boolean value.
Code:
click to view
public Geo::Vector Geo::Raster::polygonize ( hash  params)

Polygonizes the raster into a polygon OGR layer.

Parameters
[in]paramsNamed parameters that go to the constructor of Geo::Vector. Uses Polygonize from GDAL.
Returns
a new OGR layer wrapped into a Geo::Vector object.
Code:
click to view
public Geo::Raster Geo::Raster::power ( Geo::Raster  exponent,
scalar  reversed 
)

Computes the power (Perl operator **) of this raster an exponent raster.

Example:

$c = $a ** $b;

is the same as

$c = $a->power($b);
Parameters
[in]exponentA raster.
[in]reversed(optional) Whether to perform exponent ** raster computation instead of raster ** exponent. When operator '**' is used, this value is automatically set by Perl when appropriate.
Returns
the resulting raster.
Code:
click to view
public void Geo::Raster::print ( )

Prints the values of the raster grid into stdout.

Code:
click to view
public Geo::Raster Geo::Raster::prune ( Geo::Raster  fdg,
Geo::Raster  lakes,
scalar  min_length,
array  cell 
)

Delete streams that are shorter than min_length in a streams raster.

Example of removing streams shorter than min_lenght:

$streams->prune($fdg, $lakes, $min_lenght, @cell);
Parameters
[in]fdgFlow direction raster.
[in]lakes(optional) Lakes raster.
[in]min_length(optional) Minimum length (in raster scale!) of streams to be not deleted. Default is 1.5*cell_size.
[in]cell(optional) The root cell (a catchment outlet) from which the method begins to remove too short streams. If not given then all streams are pruned.
Returns
In void context changes this streams raster, otherwise returns a new streams raster.
Code:
click to view
public Geo::Raster Geo::Raster::raise_pits ( hash  params)

Raise each pit cell to the level of its lowest neighbor in a DEM.

Parameters
[in]paramsNamed parameters:
  • z_limit=>number (optional) A threshold value for how much lower that its neighbors a cell may be before it is raised. Default is 0.
  • quiet=>boolean (optional) Whether the method should report the number of cells raised.
Returns
In void context the method changes this DEM, otherwise the method returns a new DEM.
Code:
click to view
public Geo::Raster Geo::Raster::random ( )

Return a random part of values of the values of this raster.

Returns
a new raster. In void context changes the values of this raster.
Code:
click to view
public listref Geo::Raster::rect ( array  p,
array  q,
scalar  value 
)

Get or set the cells of a rectangle.

Parameters
[in]pThe upper left corner cell.
[in]qThe lower right corner cell.
[in]value(optional) The value for the cells within the rectangle.
Returns
the values of the cells within the rectangle if value is not given. The returned value is a reference to an anonymous array of the form: (@cell, value, @cell, value, ...).
Code:
click to view
public void Geo::Raster::restore ( scalar  from)

Reads the data (but not metadata, like size or other attributes of the grid) of the raster from a file or stdin.

Parameters
[in]from(optional) filename or a filehandle. If not given data is read from stdin.
Exceptions
Thegiven filename is not valid, or the file does not open.
Code:
click to view
public Geo::Raster Geo::Raster::round ( )

Rounds the value at each cell.

Returns
a new integer raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::route ( Geo::Raster  dem,
Geo::Raster  fdg,
Geo::Raster  k,
scalar  r 
)

Route water downstream (a water state raster method).

Water in each cell of the self raster is routed downstream one time step.

Parameters
[in]demThe DEM.
[in]fdg[optional] The flow directions raster.
[in]kThe flow coefficient.
[in]r[optional]. Unit of z divided by the unit of x and y in the DEM. Default is 1.
Todo:
IN DEVELOPMENT DO NOT USE
Returns
The change in water state.
Code:
click to view
public void Geo::Raster::save ( scalar  filename,
scalar  format 
)

Save libral raster into a pair of hdr and bil files.

Only genuine libral rasters are saved, i.e, rasters, which are GDAL raster caches are not saved. Extensions .bil and .asc are chopped of from the filename, but the extension .asc may be used to force saving the raster as Arc/Info ASCII.

Parameters
[in]filename(optional) Filename for the data files. If not given then the method tries to use the name attribute of the grid.
[in]format(optional). If given and contains Arc/Info ASCII, the grid is saved as such.
Exceptions
Thegiven filename is not valid, or the file does not open with writing permissions.
Code:
click to view
public void Geo::Raster::save_as_image ( scalar  filename,
scalar  type,
listref  option_keys,
listref  option_values 
)

Saves the grid as image (*.jpeg, *.png, *.tiff, *.ico or *.bmp).

Parameters
[in]filenameA string containing the filename where the image is saved.
[in]typeName of format of the image to create. Supported are jpeg, png, tiff, ico and bmp.
[in]option_keys(optional). Name of options to set. Can be used for passing metadata.
[in]option_values(optional). Values for the named options.
Code:
click to view
public method Geo::Raster::schema ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::segment ( )

Undocumented Method

Code:
click to view
public void Geo::Raster::set ( array  cell,
scalar  value 
)

Set the value of a cell.

Example of setting to single cell a new value:

$a->set($i, $j, $value);

Example of setting to single cell a nodata value:

$a->set($i, $j);
Parameters
[in]cell(optional) the cell coordinates
[in]value(optional) The value to set, which can be a number, "nodata" or a raster. Default is "nodata".
Code:
click to view
public method Geo::Raster::shallow_copy ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::sin ( )

Calculates the sine at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::sinh ( )

Calculates the hyperbolic sine at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public method Geo::Raster::size ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::slope ( scalar  z_factor)

Estimate the slope from a DEM.

The slope is computed from a 9-term quadratic polynomial fitted independently on each cell of the DEM. The slope is stored in radians.

Parameters
[in]z_factorThe unit of z divided by the unit of x and y. Default is 1.
Returns
a slope raster. In void context converts the DEM.
Code:
click to view
public method Geo::Raster::spread ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::spread_random ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::sqrt ( )

Calculates the square root at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::subcatchments ( Geo::Raster  fdg,
Geo::Raster  lakes,
array  cell,
scalar  head 
)

Divide catchments into subcatchments defined by a streams raster.

Example of usage:

$subcatchments = $streams->subcatchments($fdg, @cell);

or

($subcatchments, $topo) = $streams->subcatchments($fdg, $lakes, @cell);
Parameters
[in]fdgThe FDG from which the streams raster has been computed.
[in]lakes(optional) Lakes raster.
[in]cell(optional) The outlet cell of the catchment.
[in]head(optional) Boolean value denoting whether the algorithm should divide the catchment of a headstream to the catchment of the first cell of the headstream and the catchment draining to the rest of the headstream. Default is false.
Returns
Returns a subcatchments raster or a subcatchments raster and topology, topology is a reference to a hash of $upstream_element=>$downstream_element associations.
Code:
click to view
public Geo::Raster Geo::Raster::subtract ( Geo::Raster  second)

Subtracts from the cell value the respective cell values of the given raster.

Example of subtraction

$a -= $b;

is the same as

$a->subtract($b);
Parameters
[in]secondA raster, whose cell values are to be subtracted from the cell values of this raster.
Code:
click to view
public method Geo::Raster::sum ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::table ( )

Undocumented Method

Code:
click to view
public Geo::Raster Geo::Raster::tan ( )

Calculates the tangent at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::tanh ( )

Calculates the hyperbolic tangent at each cell.

Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::thin ( hash  opt)

Thin lines in the raster.

This is an implementation of the algorithm in Jang, B-K., Chin, R.T. 1990. Analysis of Thinning Algorithms Using Mathematical Morphology. IEEE Trans. Pattern Analysis and Machine Intelligence. 12(6). 541-551. (Same as in GRASS but done in a bit different, and more generic way, I believe).

The thinning algorithm defines a set of structuring templates and applies them in several passes until there are no matches or until the maxiterations is reached. Trimming means certain structuring templates are applied to kill emerging short limbs which appear because of the noise in the raster.

Exple of thinning:

$thinned_img = $img->thin(%options);

or

$img->thin(%options);
Parameters
[in]optIncludes as named parameters:
  • algorithm => character (optional). By default "B", the other option is "A".
  • trimming => binary (optional). By default 0, the other option is 1. Trimming removes artificial branches which grow on the side of wide lines in thinnning, but it also shortens a bit the real branches.
  • maxiterations => integer (optional). By default 0 (no maximum, will iterate until no cells are deleted).
  • width => double (optional). Used to define the maximum iterations count. In case the width is given then the maxiterations is set to int(width/2).
Returns
a new raster. In void context changes this raster.
Note
The thinned raster must be a binary raster.
Code:
click to view
public Geo::Raster Geo::Raster::times ( Geo::Raster  second)

Multiplies the cell values of this raster with the cell values of another raster.

Example:

$c = $a * $b;

is the same as

$c = $a->times($b);

The effect of raster multiplication is

for all cells: c[cell] = a[cell]*b[cell]
Parameters
[in]secondThe multiplier raster.
Returns
a new raster.
Code:
click to view
public Geo::Raster Geo::Raster::to_power_of ( Geo::Raster  second)

Raises the cell values to the power of the respective cell values of the given raster.

Example:

$a **= $b;

is the same as

$a->to_power_of($b);
Parameters
[in]secondA raster, whose cell values are used as exponents.
Code:
click to view
public listref Geo::Raster::transect ( Geo::GDAL::Geometry  geom,
scalar  delta 
)
Code:
click to view
public Geo::Raster Geo::Raster::transform ( listref  tr,
scalar  M,
scalar  N,
scalar  pick,
scalar  value 
)

Transformation (of type conversion, because just a mathematical transformation) of the raster grid.

If $pick is "count" then $value should be the value which needs to be counted – this works only for integer grids. Result grid is the same type as input except for mean and variance which are a lways floats. Division by n-1 is used for calculating variance.

In the case when $pick is not defined, the value which is stored into the target grid is looked up from the source grid using the equations above, and rounding the indexes to the nearest integer value.

In the case when $pick is defined, the value which is stored into the target grid is calculated from the (possibly rectangular) area into which the i2,j2 cell maps to. NOTE: In this case the cell coordinates are assumed to denote the upper left corner of the cell. This makes it easy to keep the (x,y) of the upper left the same BUT it is different than the usual assumption that (i, j) denotes the center of the cell.

Example of transforming

$g2 = $g1->transform(\@tr, $M, $N, $pick, $value);

Or, again just (changes the g1 instead of creating a new grid):

$g1->transform(\@tr, $M, $N, $pick, $value);

g2 will be of size M, N. Transformation uses equations:

i1 = ai + bi * i2 + ci * j2

j1 = aj + bj * i2 + cj * j2

whose parameters are in array tr:

@tr = (ai, bi, ci, aj, bj, cj);
Parameters
[in]trReference to an array having the affine tranformation parameters (i1 = tr[0] + tr[1]*i2 + tr[2]*j2, j1 = tr[3] + tr[4]*i2 + tr[5]*j2)
[in]MHeight of the area to transform in grid coordinates as integer.
[in]NWidth of the area to transform in grid coordinates as integer.
[in]pick(optional) May be "mean", "variance", "min", "max", or "count".
[in]value(optional) Should be given if pick method "count" is used, in which case the cells will include the amount of values.
Returns
a new raster. In void context changes this raster.
Code:
click to view
public Geo::Raster Geo::Raster::ucg ( )

Compute an upslope cell raster (UCG) from a FDG.

In a UCG the upslope cells of a cell are coded with the 8 bits of a byte. The directions are from 1 (up) to 8 (up left).

Returns
a UCG. In void context converts the FDG.
Code:
click to view
public Geo::Raster Geo::Raster::upslope_count ( Geo::Raster  mask,
scalar  include_self 
)

Compute the count of the upslope cells in a FDG.

Parameters
[in]mask(optional) Can be used to mask out cells from the count. Nodata cells of the mask are not included in the count.
[in]include_self(optional) Boolean value, which specifies whether the cell itself is included in its upslope area. Default is true.
Returns
the upslope count raster. In void context changes the FDG.
Note
DO NOT call if the FDG contains loops.
This is the method for computing an upslope area raster (UAG) from a flow direction raster (FDG).
Code:
click to view
public Geo::Raster Geo::Raster::upslope_sum ( Geo::Raster  a,
scalar  include_self 
)

Compute the sum of the values of the upslope cells in a raster (FDG method).

Parameters
[in]aThe operand raster.
[in]include_self(optional). Boolean value specifying whether the cell itself is included in its upslope area. Default is true.
Returns
In void context changes this flow direction raster, otherwise returns a new FDG.
Note
DO NOT call if the FDG contains loops.
Code:
click to view
public method Geo::Raster::upstream ( )

Undocumented Method

Code:
click to view
public list Geo::Raster::value_range ( hash  params)

Returns the minimum and maximum values of the raster.

Parameters
[in]paramsNamed parameters:
  • field_name The attribute whose min and max values are looked up.
Returns
array (min,max)
Code:
click to view
public method Geo::Raster::variance ( )

Undocumented Method

Code:
click to view
public array Geo::Raster::variogram ( scalar  max_lag,
scalar  lags 
)

Computes a variogram from the raster.

Parameters
[in]max_lagmaximum distance to which the variogram is computed
[in]lagsthe number of ranges of h used in computing the variogram
Returns
a list of lists (h, y(h))
Code:
click to view
public method Geo::Raster::vectorize_catchment ( hashref  topology,
Geo::Raster  streams,
Geo::Raster  lakes,
hash  params 
)

Save the subcatchment structure as a vector layer (a subcatchments raster method).

Parameters
[in]topologyReference to an hash having as keys = type id i j, and as values = type id.
[in]fdgFlow direction raster.
[in]streamsStreams raster with unique ids for segments.
[in]lakes(required if topology contains lakes) Lakes raster.
[in]paramsParameters (driver, data_source) for the new Geo::Vectors.
Returns
Two Geo::Vector objects in an array: ($subcatchments, $streams).
Code:
click to view
public void Geo::Raster::vectorize_streams ( Geo::Raster  fdg,
array  cell 
)

Create an OGR layer from a streams raster.

Parameters
fdgThe FDG from which the streams raster has been computed.
cellThe outlet cell of the catchment.
Todo:
IN DEVELOPMENT DO NOT USE
Code:
click to view
public method Geo::Raster::w2g ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::wa2ga ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::width ( )

Undocumented Method

Code:
click to view
public method Geo::Raster::world ( )

Undocumented Method

Code:
click to view
public hashref Geo::Raster::zonal_count ( Geo::Raster  zones)

Calculates the amount of cells in each zone.

Example:

$zonalcount = $a->zonal_count($zones);
$count_at_zone_1 = $zonalcount->{1};
Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
Returns
a reference to a hash that has as keys the zones and as values the number of cells, which have a defined value, within that zone.
Code:
click to view
public hashref Geo::Raster::zonal_fct ( Geo::Raster  zones,
scalar  fct 
)

Calculates a statistic of zonal values.

Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
fct(string) a method supported by Statistics::Descriptive. Default is mean.
Returns
a reference to a hash, which has the zone integers as keys and the statistics as values.
Note
Uses internally the zones method and may thus be slow and memory intensive.
Code:
click to view
public hashref Geo::Raster::zonal_max ( Geo::Raster  zones)

Calculates the maximum of this rasters cells for each zone.

Example of getting highest value for each zone:

$zonalmax = $a->zonal_max($zones);
Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
Returns
a reference to a hash that has as keys the zones and as values the maximum value within that zone.
Code:
click to view
public hashref Geo::Raster::zonal_mean ( Geo::Raster  zones)

Calculates the mean of this rasters cells for each zone.

Example of getting mean of all values for each zone:

$zonalmean = $a->zonal_mean($zones);
Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
Returns
a reference to a hash that has as keys the zones and as values the average value within that zone.
Code:
click to view
public hashref Geo::Raster::zonal_min ( Geo::Raster  zones)

Calculates the minimum of this rasters cells for each zone.

Example of getting smallest value for each zone:

$zonalmin = $a->zonal_min($zones);
Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
Returns
a reference to a hash that has as keys the zones and as values the minimum value within that zone.
Code:
click to view
public hashref Geo::Raster::zonal_sum ( Geo::Raster  zones)

Calculates the sum of this rasters cells for each zone.

Example of getting sum of values for each zone:

$zonalsum = $a->zonal_sum($zones);
Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
Returns
a reference to a hash that has as keys the zones and as values the sum of cells within that zone.
Code:
click to view
public hashref Geo::Raster::zonal_variance ( Geo::Raster  zones)

Calculates the variance of this rasters cells for each zone.

Example of getting variance of all values for each zone:

$zonalvar = $a->zonal_variance($zones);
Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
Returns
a reference to a hash that has as keys the zones and as values the variance of the values within that zone.
Code:
click to view
public hashref Geo::Raster::zones ( Geo::Raster  zones)

Returns the values from the raster in a hash indexed by the zones.

Parameters
[in]zonesAn integer raster. Each zone is defined by a unique integer.
Returns
A reference to a hash, which has the zone integers as keys and the zonal values in an anonymous array referenced by the hash values.
Exceptions
Thezone raster is not an integer raster.
Note
The returned hash contains all values from the raster and thus may be very large.
Code:
click to view

Member Data Documentation

public method Geo::Raster::AUTOLOAD
static

Undocumented Method

Code:
click to view

Definition at line 70 of file Raster.pm.


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