LSDTopoTools
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Protected Attributes | List of all members
LSDIndexRaster Class Reference

Object to handle integer rasters. More...

#include <LSDIndexRaster.hpp>

Public Member Functions

 LSDIndexRaster ()
 The create function. This is default and throws an error. More...
 
 LSDIndexRaster (string filename, string extension)
 Create an LSDIndexRaster from a file. Uses a filename and file extension. More...
 
 LSDIndexRaster (int nrows, int ncols, float xmin, float ymin, float cellsize, int ndv, Array2D< int > data)
 Create an LSDIndexRaster from memory. More...
 
 LSDIndexRaster (int nrows, int ncols, float xmin, float ymin, float cellsize, int ndv, Array2D< int > data, map< string, string > GRS_map)
 Create an LSDIndexRaster from memory. More...
 
 LSDIndexRaster (int nrows, int ncols, float xmin, float ymin, float cellsize, int ndv, map< string, string > GRS_map, int ConstValue)
 Create an LSDIndexRaster with a constant value. More...
 
 LSDIndexRaster (LSDRaster &NonIntLSDRaster)
 Create an LSDIndexRaster from an LSDRaster object, rounding to nearest int. More...
 
 LSDIndexRaster (LSDRaster &ARaster, int ConstValue)
 Create an LSDIndexRaster that is the same size as a raster but all values are some constant value. More...
 
int get_NRows () const
 
int get_NCols () const
 
float get_XMinimum () const
 
float get_YMinimum () const
 
float get_DataResolution () const
 
int get_NoDataValue () const
 
Array2D< int > get_RasterData () const
 
map< string, string > get_GeoReferencingStrings () const
 
LSDIndexRasteroperator= (const LSDIndexRaster &LSDIR)
 Assignment operator.
 
void read_raster (string filename, string extension)
 Read a raster into memory from a file. More...
 
vector< int > get_list_of_values ()
 Return the list of value but check if it has been initialized. More...
 
void write_raster (string filename, string extension)
 Read a raster from memory to a file. More...
 
int get_data_element (int row, int column)
 Get the raster data at a specified location. More...
 
void set_data_element (int row, int column, int data)
 Sets the raster data at a specified location. More...
 
void get_x_and_y_locations (int row, int col, double &x_loc, double &y_loc)
 this gets the x and y location of a node at row and column More...
 
void get_x_and_y_locations (int row, int col, float &x_loc, float &y_loc)
 this gets the x and y location of a node at row and column More...
 
void get_lat_and_long_locations (int row, int col, double &lat, double &longitude, LSDCoordinateConverterLLandUTM Converter)
 a function to get the lat and long of a node in the raster Assumes WGS84 ellipsiod More...
 
int get_value_of_point (float UTME, float UTMN)
 This gets the value at a point in UTM coordinates. More...
 
void get_UTM_information (int &UTM_zone, bool &is_North)
 this function gets the UTM_zone and a boolean that is true if the map is in the northern hemisphere More...
 
void FlattenToCSV (string FileName)
 Method to flatten an LSDIndexRaster and place the non NDV values in a csv file. Each value is placed on its own line, so that it can be read more quickly in python etc. It includes the x and y locations so it can be read by GIS software. More...
 
void FlattenToWGS84CSV (string FileName)
 Method to flatten an LSDIndexRaster and place the non NDV values in a csv file. More...
 
bool does_raster_have_same_dimensions (LSDRaster &Compare_raster)
 Checks to see if two rasters have the same dimensions Does NOT check georeferencing. More...
 
bool does_raster_have_same_dimensions (LSDIndexRaster &Compare_raster)
 Checks to see if two rasters have the same dimensions Does NOT check georeferencing. More...
 
bool does_raster_have_same_dimensions_and_georeferencing (LSDRaster &Compare_raster)
 Checks to see if two rasters have the same georeferencing. More...
 
bool does_raster_have_same_dimensions_and_georeferencing (LSDIndexRaster &Compare_raster)
 Checks to see if two rasters have the same georeferencing. More...
 
LSDIndexRaster clip_to_smaller_raster (LSDRaster &smaller_raster)
 This returns a clipped raster that has the same dimensions as the smaller raster. More...
 
LSDIndexRaster clip_to_smaller_raster (LSDIndexRaster &smaller_raster)
 This returns a clipped raster that has the same dimensions as the smaller raster. More...
 
map< string, string > Update_GeoReferencingStrings (float NewXmin, float NewYmax)
 Method which takes a new xmin and ymax value and modifys the GeoReferencingStrings map_info line to contain these new values. More...
 
void Update_GeoReferencingStrings ()
 Method which updates the map info element of the georeferencing strings based on information within the datamembers of the raster. More...
 
void impose_georeferencing_UTM (int zone, string NorS)
 This method imposes georefereing strings assuming the coordinate system is UTM. More...
 
int Find_UTM_central_meridian (int UTM_zone)
 This method looks up the central meridian given a UTM zone. More...
 
bool check_if_point_is_in_raster (float X_coordinate, float Y_coordinate)
 this check to see if a point is within the raster More...
 
void get_row_and_col_of_a_point (float X_coordinate, float Y_coordinate, int &row, int &col)
 Gets the row and column of a point in the raster. More...
 
LSDIndexRaster RasterTrimmer ()
 Calculate the minimum bounding rectangle for an LSDIndexRaster Object and crop out all the surrounding NoDataValues to reduce the size and load times of output rasters. More...
 
void get_points_in_holes_for_interpolation (int NSteps, int NSweeps, vector< float > &UTME, vector< float > &UTMN, vector< int > &row_nodes, vector< int > &col_nodes)
 This function runs the hole finding algorithm but instead of printing a raster it returns the points that are in holes. This can be used for interpolation. More...
 
LSDIndexRaster find_holes_with_nodata_bots (int NSteps, int NSweeps)
 This is a brute force method for finding all the nodata regions connected to the edge of the raster. More...
 
void release_random_bot (Array2D< int > &Visited, int startrow, int startcol, int NSteps)
 This takes a starting position and releases a random bot that moves about in nodata regions, marking its presence. More...
 
LSDIndexRaster LSDRasterTemplate (Array2D< int > InputData)
 Make LSDIndexRaster object using a 'template' raster and an Array2D of data. More...
 
LSDIndexRaster Resample (float OutputResolution)
 Method to resample an LSDIndexRaster to a lower resolution. More...
 
LSDIndexRaster CombineBinaryNetwork (LSDIndexRaster &Network1, LSDIndexRaster &Network2)
 Method to combine two rasters, ignoring nodata. More...
 
LSDIndexRaster MergeChannelWithFloodplain (LSDIndexRaster FloodPlain)
 Method to merge a floodplain raster with a channel raster. More...
 
LSDIndexRaster ConnectedComponents ()
 Method to identify connected components using a two pass method. More...
 
LSDIndexRaster filter_by_connected_components (int connected_components_threshold)
 Method to filter a binary array according to a connected components threshold. More...
 
LSDIndexRaster thin_to_skeleton ()
 A method to thin a multipixel feature (binary) to a single thread skeleton. More...
 
void thinningIteration (Array2D< int > &binary, int iter)
 
LSDIndexRaster find_end_points ()
 
void remove_downstream_endpoints (LSDIndexRaster CC, LSDRaster Topo)
 
LSDIndexRaster ConvertToBinary (int Value, int ndv)
 Method to convert all values in an LSDIndexRaster to a single value. More...
 
LSDIndexRaster RemoveSmallPatches (int minimum_segment_size)
 Method to remove patches generated by the connected components analysis that are smaller than a user defined threshold. More...
 
LSDIndexRaster remove_holes_in_patches (int window_radius)
 Method to remove small holes in patches from a binary raster. More...
 
LSDIndexRaster remove_holes_in_patches_connected_components (int window_radius)
 Method to remove small holes in patches from a connected components raster. Holes will only be filled if surrounded by pixels with the same CC value. More...
 
LSDIndexRaster remove_checkerboard_pattern ()
 Method to fill in checkerboard pattern from a binary raster. More...
 
vector< float > AnalysisOfQuality (LSDIndexRaster &ActualRaster)
 Function to calculate the reliability of floodplain method. More...
 
float GetAreaDifference (LSDIndexRaster &ActualRaster)
 Function to calculate the percentage area difference between two binary rasters. More...
 
void MergeIndexRasters (LSDIndexRaster &RasterToAdd)
 Function to merge data from two LSDIndexRasters WITH SAME EXTENT together. The data from the raster specified as an argument will be added (will overwrite the original raster if there is a conflict.) More...
 
void PadRaster (int NPixels)
 Function to pad values in an LSDIndexRaster by a certain number of pixels with values taken from the nearest pixel to be padded. More...
 
void detect_unique_values ()
 Function to detect and store all the unique values into the vector list_unique_values. Detect if this has already been launched to avoid relaunch. More...
 
void NoData_from_another_raster (LSDRaster &other_raster)
 Function to copy NoData Region from another raster. More...
 

Protected Attributes

int NRows
 Number of rows.
 
int NCols
 Number of columns.
 
float XMinimum
 Minimum X coordinate.
 
float YMinimum
 Minimum Y coordinate.
 
float DataResolution
 Data resolution.
 
int NoDataValue
 No data value.
 
vector< int > list_unique_values
 list of unique values, for example in case of a lithologic raster
 
map< string, string > GeoReferencingStrings
 A map of strings for holding georeferencing information.
 
Array2D< int > RasterData
 Raster data.
 

Detailed Description

Object to handle integer rasters.

Constructor & Destructor Documentation

LSDIndexRaster::LSDIndexRaster ( )
inline

The create function. This is default and throws an error.

Author
SMM
Date
01/01/12
LSDIndexRaster::LSDIndexRaster ( string  filename,
string  extension 
)
inline

Create an LSDIndexRaster from a file. Uses a filename and file extension.

Returns
LSDIndexRaster
Parameters
filenameA String, the file to be loaded.
extensionA String, the file extension to be loaded.
Author
SMM
Date
01/01/12
LSDIndexRaster::LSDIndexRaster ( int  nrows,
int  ncols,
float  xmin,
float  ymin,
float  cellsize,
int  ndv,
Array2D< int >  data 
)
inline

Create an LSDIndexRaster from memory.

Returns
LSDIndexRaster
Parameters
nrowsAn integer of the number of rows.
ncolsAn integer of the number of columns.
xminA float of the minimum X coordinate.
yminA float of the minimum Y coordinate.
cellsizeA float of the cellsize.
ndvAn integer of the no data value.
dataAn Array2D of integers in the shape nrows*ncols, containing the data to be written.
Author
SMM
Date
01/01/12
LSDIndexRaster::LSDIndexRaster ( int  nrows,
int  ncols,
float  xmin,
float  ymin,
float  cellsize,
int  ndv,
Array2D< int >  data,
map< string, string >  GRS_map 
)
inline

Create an LSDIndexRaster from memory.

Returns
LSDIndexRaster
Parameters
nrowsAn integer of the number of rows.
ncolsAn integer of the number of columns.
xminA float of the minimum X coordinate.
yminA float of the minimum Y coordinate.
cellsizeA float of the cellsize.
ndvAn integer of the no data value.
dataAn Array2D of integers in the shape nrows*ncols,
GRS_mapa map containing information about the georeferencing containing the data to be written.
Author
SMM
Date
09/09/14
LSDIndexRaster::LSDIndexRaster ( int  nrows,
int  ncols,
float  xmin,
float  ymin,
float  cellsize,
int  ndv,
map< string, string >  GRS_map,
int  ConstValue 
)
inline

Create an LSDIndexRaster with a constant value.

Returns
LSDIndexRaster
Parameters
nrowsAn integer of the number of rows.
ncolsAn integer of the number of columns.
xminA float of the minimum X coordinate.
yminA float of the minimum Y coordinate.
cellsizeA float of the cellsize.
ndvAn integer of the no data value.
GRS_mapa map containing information about the georeferencing
ConstValuethe value all elements in array have containing the data to be written.
Author
SMM
Date
20/05/16
LSDIndexRaster::LSDIndexRaster ( LSDRaster NonIntLSDRaster)
inline

Create an LSDIndexRaster from an LSDRaster object, rounding to nearest int.

Returns
LSDIndexRaster
Parameters
NonIntLSDRasteran LSDRaster object containing flaoting point data
Author
MDH
Date
17/02/15
LSDIndexRaster::LSDIndexRaster ( LSDRaster ARaster,
int  ConstValue 
)
inline

Create an LSDIndexRaster that is the same size as a raster but all values are some constant value.

Parameters
NonIntLSDRasteran LSDRaster object
CanstValuea value that will be assigned to all data points
Author
SMM
Date
19/05/16

Member Function Documentation

vector< float > LSDIndexRaster::AnalysisOfQuality ( LSDIndexRaster ActualRaster)

Function to calculate the reliability of floodplain method.

Parameters
ActualRasterraster of actual values
Author
FJC
Date
26/06/16
bool LSDIndexRaster::check_if_point_is_in_raster ( float  X_coordinate,
float  Y_coordinate 
)

this check to see if a point is within the raster

Parameters
X_coordinatethe x location of the point
Y_coordinatethe y location of the point
Returns
is_in_raster a boolean telling if the point is in the raster
Author
SMM
Date
13/11/2014
LSDIndexRaster LSDIndexRaster::clip_to_smaller_raster ( LSDRaster smaller_raster)

This returns a clipped raster that has the same dimensions as the smaller raster.

Parameters
smaller_rasterthe raster to which the bigger raster should be clipped
Author
SMM
Date
20/03/2015
LSDIndexRaster LSDIndexRaster::clip_to_smaller_raster ( LSDIndexRaster smaller_raster)

This returns a clipped raster that has the same dimensions as the smaller raster.

Parameters
smaller_rasterthe raster to which the bigger raster should be clipped
Author
SMM
Date
20/03/2015
LSDIndexRaster LSDIndexRaster::CombineBinaryNetwork ( LSDIndexRaster Network1,
LSDIndexRaster Network2 
)

Method to combine two rasters, ignoring nodata.

Parameters
Network1The first raster to be combined.
Network2The second raster to be combined.
Returns
An LSDIndexRaster of the combined inputs.
Author
SWDG
Date
17/6/14
LSDIndexRaster LSDIndexRaster::ConnectedComponents ( )

Method to identify connected components using a two pass method.

Takes a binary array, where components parts are identifed by 1 and separates into connected components according to a two-pass algorithm based on that described in He et al. (2008), "A Run-Based Two-Scan Labeling Algorithm," Image Processing, IEEE Transactions on , vol.17, no.5, pp.749,756, doi: 10.1109/TIP.2008.919369

Returns
an LSDRaster with labelled connected components
Author
DTM
Date
13/07/2015
LSDIndexRaster LSDIndexRaster::ConvertToBinary ( int  Value,
int  ndv 
)

Method to convert all values in an LSDIndexRaster to a single value.

Parameters
Value,aninteger value that will be assigned to every non NDV cell in the raster.
ndvan integer no data value.
Author
SWDG
Date
24/07/2015
void LSDIndexRaster::detect_unique_values ( )

Function to detect and store all the unique values into the vector list_unique_values. Detect if this has already been launched to avoid relaunch.

Parameters
Noparam
Returns
Nothing, change directly the protected vector attribute
Author
BG
Date
17/09/17
bool LSDIndexRaster::does_raster_have_same_dimensions ( LSDRaster Compare_raster)

Checks to see if two rasters have the same dimensions Does NOT check georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
04/05/2015
bool LSDIndexRaster::does_raster_have_same_dimensions ( LSDIndexRaster Compare_raster)

Checks to see if two rasters have the same dimensions Does NOT check georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
04/05/2015
bool LSDIndexRaster::does_raster_have_same_dimensions_and_georeferencing ( LSDRaster Compare_raster)

Checks to see if two rasters have the same georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
02/03/2015
bool LSDIndexRaster::does_raster_have_same_dimensions_and_georeferencing ( LSDIndexRaster Compare_raster)

Checks to see if two rasters have the same georeferencing.

Parameters
Compare_rasterthe raster to compare
Author
SMM
Date
02/03/2015
LSDIndexRaster LSDIndexRaster::filter_by_connected_components ( int  connected_components_threshold)

Method to filter a binary array according to a connected components threshold.

Author
DTM
Date
22/07/2015
LSDIndexRaster LSDIndexRaster::find_holes_with_nodata_bots ( int  NSteps,
int  NSweeps 
)

This is a brute force method for finding all the nodata regions connected to the edge of the raster.

Parameters
NStepsthe number of steps for each cellular automata bot
NSweepsthe number of times the raster is swept
Returns
a raster with 0 for non-visited points and and integer elsewhere
Author
SMM
Date
17/3/2017
int LSDIndexRaster::Find_UTM_central_meridian ( int  UTM_zone)

This method looks up the central meridian given a UTM zone.

Parameters
UTM_zonethe UTM zone
Returns
central_meridian an integer of the central meridian of this UTM zone
Author
SMM
Date
6/11/14
void LSDIndexRaster::FlattenToCSV ( string  FileName)

Method to flatten an LSDIndexRaster and place the non NDV values in a csv file. Each value is placed on its own line, so that it can be read more quickly in python etc. It includes the x and y locations so it can be read by GIS software.

Parameters
FileName_prefixThe prefix of the file to write, if no path is included it will write to the current directory. The csv extension is added automatically.
Author
SMM
Date
29/6/15
void LSDIndexRaster::FlattenToWGS84CSV ( string  FileName)

Method to flatten an LSDIndexRaster and place the non NDV values in a csv file.

Each value is placed on its own line, so that it can be read more quickly in python etc. It includes the lat long coordinates in CSV

Parameters
FileName_prefixThe prefix of the file to write, if no path is included it will write to the current directory. The csv extension is added automatically.
Author
SMM
Date
12/11/16
int LSDIndexRaster::get_data_element ( int  row,
int  column 
)
inline

Get the raster data at a specified location.

Parameters
rowAn integer, the X coordinate of the target cell.
columnAn integer, the Y coordinate of the target cell.
Returns
The raster value at the position (row, column).
Author
SMM
Date
01/01/12
float LSDIndexRaster::get_DataResolution ( ) const
inline
Returns
Data resolution as an integer.
map<string,string> LSDIndexRaster::get_GeoReferencingStrings ( ) const
inline
Returns
Map of strings containing georeferencing information
void LSDIndexRaster::get_lat_and_long_locations ( int  row,
int  col,
double &  lat,
double &  longitude,
LSDCoordinateConverterLLandUTM  Converter 
)

a function to get the lat and long of a node in the raster Assumes WGS84 ellipsiod

Parameters
rowthe row of the node
colthe col of the node
latthe latitude of the node (in decimal degrees, replaced by function) Note: this is a double, because a float does not have sufficient precision relative to a UTM location (which is in metres)
longthe longitude of the node (in decimal degrees, replaced by function) Note: this is a double, because a float does not have sufficient precision relative to a UTM location (which is in metres)
Convertera converter object (from LSDShapeTools)
Author
SMM
Date
24/05/2015
vector< int > LSDIndexRaster::get_list_of_values ( )

Return the list of value but check if it has been initialized.

Author
BG
Date
19/09/2017
int LSDIndexRaster::get_NCols ( ) const
inline
Returns
Number of columns as an integer.
int LSDIndexRaster::get_NoDataValue ( ) const
inline
Returns
No Data Value as an integer.
int LSDIndexRaster::get_NRows ( ) const
inline
Returns
Number of rows as an integer.
void LSDIndexRaster::get_points_in_holes_for_interpolation ( int  NSteps,
int  NSweeps,
vector< float > &  UTME,
vector< float > &  UTMN,
vector< int > &  row_nodes,
vector< int > &  col_nodes 
)

This function runs the hole finding algorithm but instead of printing a raster it returns the points that are in holes. This can be used for interpolation.

Parameters
NStepsthe number of steps for each cellular automata bot
NSweepsthe number of times the raster is swept
UTMEthe easting coordinates of the hole points (overwritten)
UTMNthe northing coordinates of the hole points (overwritten)
row_nodesthe row numbers of the hole nodes (overwritten)
col_nodesthe col numbers of the hole nodes (overwritten)
Author
SMM
Date
17/03/2017
Array2D<int> LSDIndexRaster::get_RasterData ( ) const
inline
Returns
Raster values as a 2D Array.
void LSDIndexRaster::get_row_and_col_of_a_point ( float  X_coordinate,
float  Y_coordinate,
int &  row,
int &  col 
)

Gets the row and column of a point in the raster.

Parameters
X_coordinatethe x location of the point
Y_coordinatethe y location of the point
rowthe row of the point, replaced upon running the routine
colthe col of the point, replaced upon running the routine
Author
SMM
Date
22/01/2016
void LSDIndexRaster::get_UTM_information ( int &  UTM_zone,
bool &  is_North 
)

this function gets the UTM_zone and a boolean that is true if the map is in the northern hemisphere

Parameters
UTM_zonethe UTM zone. Replaced in function.
is_Northa boolean that is true if the DEM is in the northern hemisphere. replaced in function
Author
SMM
Date
22/12/2014
int LSDIndexRaster::get_value_of_point ( float  UTME,
float  UTMN 
)

This gets the value at a point in UTM coordinates.

Parameters
UTMEthe easting coordinate
UTMNthe northing coordinate
Returns
The value at that point
Author
SMM
Date
14/03/2017
void LSDIndexRaster::get_x_and_y_locations ( int  row,
int  col,
double &  x_loc,
double &  y_loc 
)

this gets the x and y location of a node at row and column

Parameters
rowthe row of the node
colthe column of the node
x_locthe x location (Northing) of the node
y_locthe y location (Easting) of the node
Author
SMM
Date
22/12/2014
void LSDIndexRaster::get_x_and_y_locations ( int  row,
int  col,
float &  x_loc,
float &  y_loc 
)

this gets the x and y location of a node at row and column

Parameters
rowthe row of the node
colthe column of the node
x_locthe x location (Northing) of the node
y_locthe y location (Easting) of the node
Author
SMM
Date
22/12/2014
float LSDIndexRaster::get_XMinimum ( ) const
inline
Returns
Minimum X coordinate as an integer.
float LSDIndexRaster::get_YMinimum ( ) const
inline
Returns
Minimum Y coordinate as an integer.
float LSDIndexRaster::GetAreaDifference ( LSDIndexRaster ActualRaster)

Function to calculate the percentage area difference between two binary rasters.

Parameters
ActualRasterraster of actual values
Returns
Percentage difference betwen the area of the two rasters
Author
FJC
Date
18/01/17
void LSDIndexRaster::impose_georeferencing_UTM ( int  zone,
string  NorS 
)

This method imposes georefereing strings assuming the coordinate system is UTM.

Parameters
zonethe UTM zone
NorSa string containing characters that start either N (for north) or S for south. The letter is not case sensitive
Author
SMM
Date
6/11/14
LSDIndexRaster LSDIndexRaster::LSDRasterTemplate ( Array2D< int >  InputData)

Make LSDIndexRaster object using a 'template' raster and an Array2D of data.

Parameters
InputData2DArray of ints to be written to LSDIndexRaster.
Returns
LSDRaster containing the data passed in.
Author
SWDG
Date
02/9/13
LSDIndexRaster LSDIndexRaster::MergeChannelWithFloodplain ( LSDIndexRaster  FloodPlain)

Method to merge a floodplain raster with a channel raster.

Creates an output LSDIndexRaster which is coded coded channel == input channel index, floodplain == 500, NDV == hillslopes. This allows the preservation of the stream order in addition to the floodplain geometry.

Parameters
FloodPlainan LSDIndexRaster of the floodplains coded with any integer value.
Returns
An LSDIndexRaster of the merged channels and floodplains.
Author
SWDG
Date
05/03/15
void LSDIndexRaster::MergeIndexRasters ( LSDIndexRaster RasterToAdd)

Function to merge data from two LSDIndexRasters WITH SAME EXTENT together. The data from the raster specified as an argument will be added (will overwrite the original raster if there is a conflict.)

Parameters
RasterToAddthe raster to merge
Returns
LSDIndexRaster merged raster
Author
FJC
Date
07/04/17
void LSDIndexRaster::NoData_from_another_raster ( LSDRaster other_raster)

Function to copy NoData Region from another raster.

Parameters
LSDRasterOtherRaster
Returns
Nothing, change directly the value of the raster
Author
BG
Date
20/09/2017
void LSDIndexRaster::PadRaster ( int  NPixels)

Function to pad values in an LSDIndexRaster by a certain number of pixels with values taken from the nearest pixel to be padded.

Parameters
NPixelsthe number of pixels to pad by
Returns
LSDIndexRaster padded raster
Author
MDH
Date
20/07/17
LSDIndexRaster LSDIndexRaster::RasterTrimmer ( )

Calculate the minimum bounding rectangle for an LSDIndexRaster Object and crop out all the surrounding NoDataValues to reduce the size and load times of output rasters.

Ideal for use with chi analysis tools which output basin and chi m value rasters which can be predominantly no data. As an example, a 253 Mb file can be reduced to ~5 Mb with no loss or resampling of data.

Returns
A trimmed LSDIndexRaster object.
Author
SWDG
Date
22/08/13
void LSDIndexRaster::read_raster ( string  filename,
string  extension 
)

Read a raster into memory from a file.

The supported formats are .asc and .flt which are both exported and imported by arcmap.

The filename is the string of characters before the '.' in the extension and the extension is the characters after the '.'.

If the full filename is my_dem.01.asc then: filename = "my_dem.01" and extension = "asc".

For float files both a data file and a header are read the header file must have the same filename, before extention, of the raster data, and the extension must be .hdr.

Author
SMM
Date
01/01/12
void LSDIndexRaster::release_random_bot ( Array2D< int > &  Visited,
int  startrow,
int  startcol,
int  NSteps 
)

This takes a starting position and releases a random bot that moves about in nodata regions, marking its presence.

Parameters
Visitedand array of numbers for the number of times a pixel is visited
startrowthe starting row
startcolthe starting column
NStepsthe number of steps the bot takes
Author
SMM
Date
17/03/2017
LSDIndexRaster LSDIndexRaster::remove_checkerboard_pattern ( )

Method to fill in checkerboard pattern from a binary raster.

Author
FJC
Date
30/10/15
LSDIndexRaster LSDIndexRaster::remove_holes_in_patches ( int  window_radius)

Method to remove small holes in patches from a binary raster.

Parameters
window_radiusradius over which to search to remove holes (size of hole)
Author
FJC
Date
22/10/15
LSDIndexRaster LSDIndexRaster::remove_holes_in_patches_connected_components ( int  window_radius)

Method to remove small holes in patches from a connected components raster. Holes will only be filled if surrounded by pixels with the same CC value.

Parameters
window_radiusradius over which to search to remove holes (size of hole)
Author
FJC
Date
20/01/16
LSDIndexRaster LSDIndexRaster::RemoveSmallPatches ( int  minimum_segment_size)

Method to remove patches generated by the connected components analysis that are smaller than a user defined threshold.

Parameters
minimum_segment_sizeSize in pixels below which a patch should be removed.
Author
SWDG
Date
17/9/15
LSDIndexRaster LSDIndexRaster::Resample ( float  OutputResolution)

Method to resample an LSDIndexRaster to a lower resolution.

Parameters
OutputResolutionthe resolution in spatial units to be resampled to.
Returns
An LSDIndexRaster resampled to the OutputResolution.
Author
SWDG
Date
17/3/14
void LSDIndexRaster::set_data_element ( int  row,
int  column,
int  data 
)
inline

Sets the raster data at a specified location.

Parameters
rowAn integer, the X coordinate of the target cell.
columnAn integer, the Y coordinate of the target cell.
valuethe vaule of the data element at the give row and column
Returns
The raster value at the position (row, column).
Author
SMM
Date
18/03/15
LSDIndexRaster LSDIndexRaster::thin_to_skeleton ( )

A method to thin a multipixel feature (binary) to a single thread skeleton.

Takes a binary array in which features are identified as 1, and background 0, and thins the features down to a skeleton, using the thinning algorithm described by Zhang and Suen, 1984, "A fast algorithm for thinning digital patterns", Communications of the ACM.

Returns
an LSDIndexRaster with the skeleton
Author
DTM
Date
15/07/2015
map< string, string > LSDIndexRaster::Update_GeoReferencingStrings ( float  NewXmin,
float  NewYmax 
)

Method which takes a new xmin and ymax value and modifys the GeoReferencingStrings map_info line to contain these new values.

Intended for use in the rastertrimmer methods and is called from within these methods. Modifying georeferencing information by hand is messy and should be avoided if at all possible.

Parameters
NewXminfloating point value of the new minimum x value in the raster.
NewYmaxfloating point value of the new maximum y value in the raster.
Returns
An updated GeoReferencingStrings object.
Author
SWDG
Date
6/11/14
void LSDIndexRaster::Update_GeoReferencingStrings ( )

Method which updates the map info element of the georeferencing strings based on information within the datamembers of the raster.

Intended for use when changing raster dimesions

Author
SMM
Date
6/11/14
void LSDIndexRaster::write_raster ( string  filename,
string  extension 
)

Read a raster from memory to a file.

The supported formats are .asc and .flt which are both exported and imported by arcmap.

The filename is the string of characters before the '.' in the extension and the extension is the characters after the '.'.

If the full filename is my_dem.01.asc then: filename = "my_dem.01" and extension = "asc".

For float files both a data file and a header are written the header file must have the same filename, before extention, of the raster data, and the extension must be .hdr.

Author
SMM
Date
01/01/12

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