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

Public Member Functions

 LSDSpatialCSVReader (string csv_fname)
 Create an LSDSpatialCSVReader from a raster and csv filenname. More...
 
 LSDSpatialCSVReader (LSDRaster &ThisRaster, string csv_fname)
 Create an LSDSpatialCSVReader from a raster and csv filenname. More...
 
 LSDSpatialCSVReader (LSDRasterInfo &ThisRaster, string csv_fname)
 Create an LSDSpatialCSVReader from a raster. More...
 
 LSDSpatialCSVReader (int nrows, int ncols, float xmin, float ymin, float cellsize, float ndv, map< string, string > temp_GRS, vector< double > &this_latitude, vector< double > &this_longitude, vector< bool > &this_is_point_in_raster, map< string, vector< string > > &this_data_map)
 Create an LSDSpatialCSVReader from all the data elements. More...
 
void load_csv_data (string filename)
 This loads a csv file, grabbing the latitude and longitude, and putting the rest of the data into data maps. More...
 
bool check_if_latitude_and_longitude_exist ()
 This tests to see if there are latitude and longitude vectors. More...
 
bool check_if_all_data_columns_same_length ()
 This tests to see if all the data columns are the same length as the latitude and longitude data columns. More...
 
void set_UTM_information (int UTM_zone, bool is_North)
 this function sets a UTM_ coordinate system string the map is in the northern hemisphere 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 get_x_and_y_from_latlong (vector< float > &UTME, vector< float > &UTMN)
 This takes latitude and longitude (in WGS 84) and converts to vectors of easting and northing in UTM. More...
 
void get_x_and_y_from_latlong_specify_columns (string lat_column_name, string long_column_name, vector< float > &UTME, vector< float > &UTMN)
 This takes latitude and longitude (in WGS 84) and converts to vectors of easting and northing in UTM. User must specify the column for lat and long (this can be used for csv files where the column is not headed simply "latitude" or "longitude". More...
 
void get_latlong_from_x_and_y (string X_column_name, string Y_column_name)
 This takes the X and Y columns in a csv, assumes they are UTM, and converts to latitude and loingitude in WGS84. More...
 
void burn_raster_data_to_csv (LSDRaster &ThisRaster, string column_name)
 Takes raster data and adds it to the data column. More...
 
void burn_raster_data_to_csv (LSDIndexRaster &ThisRaster, string column_name)
 Takes raster data and adds it to the data column. More...
 
void get_data_in_raster_for_snapping (string column_name, vector< float > &UTMEasting, vector< float > &UTMNorthing, vector< string > &data_vector)
 This gets UTM coordinates and a data vector (usually IDs) for snapping to a channel network. More...
 
vector< string > get_data_column (string column_name)
 This gets a data column from the csv file. More...
 
vector< float > data_column_to_float (string column_name)
 This gets a data column from the csv file, and converts it to a float vector. More...
 
vector< int > data_column_to_int (string column_name)
 This gets a data column from the csv file, and converts it to an int vector. More...
 
void check_if_points_are_in_raster ()
 this check to see if a point is within the raster More...
 
void get_nodeindices_from_x_and_y_coords (LSDFlowInfo &FlowInfo, vector< float > &X_coords, vector< float > &Y_coords, vector< int > &NodeIndices)
 This function gets vectors of x and y coordinates and node indices from these points. More...
 
LSDSpatialCSVReader select_data_to_new_csv_object (string selection_column, vector< string > data_for_selection)
 This selects specified data and crease a new csv object with just that data. More...
 
void print_data_map_keys_to_screen ()
 this prints keys of the data map to screen More...
 
void print_lat_long_to_screen ()
 this prints the latitude and longitude to screen More...
 
void print_lat_long_to_screen (bool only_print_in_raster)
 this prints the latitude and longitude to screen More...
 
void print_UTM_coords_to_csv (vector< float > UTME, vector< float > UTMN, string csv_outname)
 print the UTM coords to a csv file for checking More...
 
void print_data_to_csv (string csv_outname)
 print the data to a csv. Used after updating data More...
 
void print_data_to_geojson (string json_outname)
 print the data to a geojson. Used after updating data More...
 
vector< double > get_latitude () const
 Gets the various data members.
 
vector< double > get_longitude () const
 

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.
 
map< string, string > GeoReferencingStrings
 A map of strings for holding georeferencing information.
 
vector< double > latitude
 A vector of the latitude (in WGS84)
 
vector< double > longitude
 A vector of the longitude (in WGS84)
 
vector< bool > is_point_in_raster
 A vector of bools telling if the points are in the raster.
 
map< string, vector< string > > data_map
 The map.
 

Constructor & Destructor Documentation

LSDSpatialCSVReader::LSDSpatialCSVReader ( string  csv_fname)
inline

Create an LSDSpatialCSVReader from a raster and csv filenname.

Parameters
csv_fnameThe name of the csv file including extension and path
Author
SMM
Date
22/02/2017
LSDSpatialCSVReader::LSDSpatialCSVReader ( LSDRaster ThisRaster,
string  csv_fname 
)
inline

Create an LSDSpatialCSVReader from a raster and csv filenname.

Parameters
ThisRasterAn LSDRaster object
csv_fnameThe name of the csv file including extension and path
Author
SMM
Date
16/02/2017
LSDSpatialCSVReader::LSDSpatialCSVReader ( LSDRasterInfo ThisRaster,
string  csv_fname 
)
inline

Create an LSDSpatialCSVReader from a raster.

Parameters
ThisRasterAn LSDIndexRaster object
csv_fnameThe name of the csv file including extension and path
Author
SMM
Date
16/02/2017
LSDSpatialCSVReader::LSDSpatialCSVReader ( int  nrows,
int  ncols,
float  xmin,
float  ymin,
float  cellsize,
float  ndv,
map< string, string >  temp_GRS,
vector< double > &  this_latitude,
vector< double > &  this_longitude,
vector< bool > &  this_is_point_in_raster,
map< string, vector< string > > &  this_data_map 
)
inline

Create an LSDSpatialCSVReader from all the data elements.

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 floats in the shape nrows*ncols,
temp_GRSa map of strings containing georeferencing information. Used mainly with ENVI format files
this_latitudethe latitudes in WGS84
this_longitudethe longitudes in WGS84
this_is_point_in_rasterbool vec for testing if point in raster domain
this_data_mapthe data elements
Author
SMM
Date
15/03/2017

Member Function Documentation

void LSDSpatialCSVReader::burn_raster_data_to_csv ( LSDRaster ThisRaster,
string  column_name 
)

Takes raster data and adds it to the data column.

Parameters
TheRasteran LSDRaster
Author
SMM
Date
14/03/2017
void LSDSpatialCSVReader::burn_raster_data_to_csv ( LSDIndexRaster ThisRaster,
string  column_name 
)

Takes raster data and adds it to the data column.

Parameters
TheRasteran LSDIndexRaster
Author
SMM
Date
14/03/2017
bool LSDSpatialCSVReader::check_if_all_data_columns_same_length ( )

This tests to see if all the data columns are the same length as the latitude and longitude data columns.

Returns
all_data_columns_exist This is true if the data columns are the same length as the lat and long vectyors
Author
SMM
Date
14/03/2017
bool LSDSpatialCSVReader::check_if_latitude_and_longitude_exist ( )

This tests to see if there are latitude and longitude vectors.

Returns
lat_and_long_exist This is true if the lat and long vectors exist are the same length.
Author
SMM
Date
14/03/2017
void LSDSpatialCSVReader::check_if_points_are_in_raster ( )

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
vector< float > LSDSpatialCSVReader::data_column_to_float ( string  column_name)

This gets a data column from the csv file, and converts it to a float vector.

Parameters
column_namea string that holds the column name
Returns
a vector of floats: this holds the data.
Author
SMM
Date
17/02/2017
vector< int > LSDSpatialCSVReader::data_column_to_int ( string  column_name)

This gets a data column from the csv file, and converts it to an int vector.

Parameters
column_namea string that holds the column name
Returns
a vector of ints: this holds the data.
Author
SMM
Date
17/02/2017
vector< string > LSDSpatialCSVReader::get_data_column ( string  column_name)

This gets a data column from the csv file.

Parameters
column_namea string that holds the column name
Returns
a vector of strings: this holds the data.
Author
SMM
Date
17/02/2017
void LSDSpatialCSVReader::get_data_in_raster_for_snapping ( string  column_name,
vector< float > &  UTMEasting,
vector< float > &  UTMNorthing,
vector< string > &  data_vector 
)

This gets UTM coordinates and a data vector (usually IDs) for snapping to a channel network.

Parameters
column_namea string that holds the column name
UTMEastingThe easting coordinate (is overwritten)
UTMNorthingThe northing coordinate (is overwritten)
data_vectorthe data in a strong vector from the column. Usually sample ID for snapping
Author
SMM
Date
20/02/2017
void LSDSpatialCSVReader::get_latlong_from_x_and_y ( string  X_column_name,
string  Y_column_name 
)

This takes the X and Y columns in a csv, assumes they are UTM, and converts to latitude and loingitude in WGS84.

Parameters
X_column_nameName of the column in the csv with X coordinate (easting)
Y_column_nameName of the column in the csv with Y coordinate (northing)
Author
SMM
Date
22/02/2017
void LSDSpatialCSVReader::get_nodeindices_from_x_and_y_coords ( LSDFlowInfo FlowInfo,
vector< float > &  X_coords,
vector< float > &  Y_coords,
vector< int > &  NodeIndices 
)

This function gets vectors of x and y coordinates and node indices from these points.

This DOES NOT use latitude and longitude, instead it assumes that your csv file has columns labelled "X" and "Y". Can be used when you want to read in points without converting from latitude and longitude.

Parameters
FlowInfoLSDFLowInfo object
X_coordsvector to write X coords to
Y_coordsvector to write Y coords to
NodeIndicesvector to write node indices
Author
FJC
Date
21/02/17
void LSDSpatialCSVReader::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
void LSDSpatialCSVReader::get_x_and_y_from_latlong ( vector< float > &  UTME,
vector< float > &  UTMN 
)

This takes latitude and longitude (in WGS 84) and converts to vectors of easting and northing in UTM.

Parameters
UTMEThe easting coordinate (is overwritten)
UTMNThe northing coordinate (is overwritten)
Author
SMM
Date
17/02/2017
void LSDSpatialCSVReader::get_x_and_y_from_latlong_specify_columns ( string  lat_column_name,
string  long_column_name,
vector< float > &  UTME,
vector< float > &  UTMN 
)

This takes latitude and longitude (in WGS 84) and converts to vectors of easting and northing in UTM. User must specify the column for lat and long (this can be used for csv files where the column is not headed simply "latitude" or "longitude".

Parameters
lat_column_nameThe header of the latitude column (string)
long_column_nameThe header of the longitude column (string)
UTMEThe easting coordinate (is overwritten)
UTMNThe northing coordinate (is overwritten)
Author
FJC
Date
01/08/17
void LSDSpatialCSVReader::load_csv_data ( string  filename)

This loads a csv file, grabbing the latitude and longitude, and putting the rest of the data into data maps.

Parameters
filenameThe name of the csv file including path and extension
Author
SMM
Date
16/02/2017
void LSDSpatialCSVReader::print_data_map_keys_to_screen ( )

this prints keys of the data map to screen

Author
SMM
Date
20/02/2017
void LSDSpatialCSVReader::print_data_to_csv ( string  csv_outname)

print the data to a csv. Used after updating data

Parameters
csv_outnamethe name of the new file
Author
SMM
Date
13/03/17
void LSDSpatialCSVReader::print_data_to_geojson ( string  json_outname)

print the data to a geojson. Used after updating data

Parameters
json_outnamethe name of the new file
Author
SMM
Date
14/03/17
void LSDSpatialCSVReader::print_lat_long_to_screen ( )

this prints the latitude and longitude to screen

Author
SMM
Date
17/02/2017
void LSDSpatialCSVReader::print_lat_long_to_screen ( bool  only_print_in_raster)

this prints the latitude and longitude to screen

Parameters
only_print_in_rastera bool when true only prints points in raster
Author
SMM
Date
20/02/2017
void LSDSpatialCSVReader::print_UTM_coords_to_csv ( vector< float >  UTME,
vector< float >  UTMN,
string  csv_outname 
)

print the UTM coords to a csv file for checking

Parameters
UTMEeastings
UTMNnorthings
Author
FJC
Date
03/03/17
LSDSpatialCSVReader LSDSpatialCSVReader::select_data_to_new_csv_object ( string  selection_column,
vector< string >  data_for_selection 
)

This selects specified data and crease a new csv object with just that data.

Parameters
selection_columnThe name of the column from which the data will be selected
data_for_selectiona vector holding the values of the data column that will be selected. Rows without these values will be removed
Author
SMM
Date
15/03/2017
void LSDSpatialCSVReader::set_UTM_information ( int  UTM_zone,
bool  is_North 
)

this function sets a UTM_ coordinate system string 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/02/2017

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