ccgl::data_raster Namespace Reference

Raster class to handle various raster data. More...

Classes

class  clsRasterData
 Raster data (1D and 2D) I/O class Support I/O among ASCII file, TIFF, and MongoDB database. More...
 
class  SubsetPositions
 Subset positions of raster data. More...
 

Typedefs

typedef std::pair< int, int > ROW_COL
 GeoTIFF extension.
 
typedef std::pair< double, double > XY_COOR
 Row and Col pair.
 

Enumerations

enum  RasterDataType {
  RDT_Unknown , RDT_UInt8 , RDT_Int8 , RDT_UInt16 ,
  RDT_Int16 , RDT_UInt32 , RDT_Int32 , RDT_UInt64 ,
  RDT_Int64 , RDT_Float , RDT_Double
}
 Coordinate pair. More...
 

Functions

string RasterDataTypeToString (int type)
 Common functions independent to clsRasterData. More...
 
RasterDataType StringToRasterDataType (const string &stype)
 Convert string to RasterDataType.
 
RasterDataType TypeToRasterDataType (const std::type_info &t)
 Convert C++ data type to RasterDataType.
 
double DefaultNoDataByType (RasterDataType type)
 Default NoData value by data type.
 
GDALDataType CvtToGDALDataType (const RasterDataType type)
 
STRDBL_MAP InitialHeader ()
 Initialize header information in double.
 
void CopyHeader (const STRDBL_MAP &refers, STRDBL_MAP &dst)
 Copy header information from one to another. More...
 
STRING_MAP InitialStrHeader ()
 Initialize header information in string.
 
void UpdateStrHeader (STRING_MAP &strheader, const string &key, const string &val)
 Update header information in string.
 
RasterDataType RasterDataTypeInOptionals (const STRING_MAP &opts)
 Get output raster data type from optional inputs.
 
void InitialStatsMap (STRDBL_MAP &stats, map< string, double * > &stats2d)
 Initialize statistics values for 1D and 2D raster data.
 
bool WriteAscHeaders (const string &filename, const STRDBL_MAP &header)
 Write raster header information into a ASC file. More...
 
template<typename T >
void UpdateHeader (STRDBL_MAP &header, const string &key, T val)
 Update value in header information.
 
template<typename T >
bool ReadAscFile (const string &filename, STRDBL_MAP &header, T *&values)
 Read raster data from ASC file, the simply usage. More...
 
template<typename T >
bool WriteSingleAsc (const string &filename, const STRDBL_MAP &header, T *values)
 Write raster data as a single ASC file. More...
 
template<typename T >
bool ReadRasterFileByGdal (const string &filename, STRDBL_MAP &header, T *&values, RasterDataType &in_type, string &srs)
 Read single raster file by GDAL. More...
 
template<typename T >
bool WriteSingleGeotiff (const string &filename, const STRDBL_MAP &header, const STRING_MAP &opts, T *values)
 Write single geotiff file If the file exists, delete it first. More...
 
template<typename T >
bool WriteRasterToFile (const string &filename, const STRDBL_MAP &header, const STRING_MAP &opts, T *values)
 Write single raster file, if the file exists, delete it first. More...
 
template<typename T >
bool ReadGridFsFile (MongoGridFs *gfs, const string &filename, T *&data, STRDBL_MAP &header, STRING_MAP &header_str, const STRING_MAP &opts)
 Read GridFs file from MongoDB. More...
 
template<typename T >
bool WriteStreamDataAsGridfs (MongoGridFs *gfs, const string &filename, STRDBL_MAP &header, T *values, const int datalength, const STRING_MAP &opts=STRING_MAP())
 Write array data (both valid and full-sized raster data) as GridFS file. More...
 

Variables

CONST_CHARS HEADER_RS_NODATA = "NODATA_VALUE"
 
CONST_CHARS HEADER_RS_XLL = "XLLCENTER"
 NoData value.
 
CONST_CHARS HEADER_RS_YLL = "YLLCENTER"
 X coordinate value of left low center.
 
CONST_CHARS HEADER_RS_XLLCOR = "XLLCORNER"
 Y coordinate value of left low center.
 
CONST_CHARS HEADER_RS_YLLCOR = "YLLCORNER"
 X coordinate value of left low center.
 
CONST_CHARS HEADER_RS_NROWS = "NROWS"
 Y coordinate value of left low center.
 
CONST_CHARS HEADER_RS_NCOLS = "NCOLS"
 Rows number.
 
CONST_CHARS HEADER_RS_CELLSIZE = "CELLSIZE"
 Column number.
 
CONST_CHARS HEADER_RS_LAYERS = "LAYERS"
 Cell size (length)
 
CONST_CHARS HEADER_RS_CELLSNUM = "CELLSNUM"
 Layers number.
 
CONST_CHARS HEADER_RS_SRS = "SRS"
 Number of the first layer's valid cells.
 
CONST_CHARS HEADER_RS_PARAM_ABSTRACTION_TYPE = "PARAM_ABSTRACTION_TYPE"
 SRS.
 
CONST_CHARS HEADER_RS_DATATYPE = "DATATYPE"
 spatial parameter type, physical or conceptual
 
CONST_CHARS HEADER_RSOUT_DATATYPE = "DATATYPE_OUT"
 Data type of original raster.
 
CONST_CHARS HEADER_INC_NODATA = "INCLUDE_NODATA"
 Desired output data type of raster.
 
CONST_CHARS HEADER_MASK_NAME = "MASK_NAME"
 Include nodata ("TRUE") or not ("FALSE"), for DB only.
 
CONST_CHARS STATS_RS_VALIDNUM = "VALID_CELLNUMBER"
 Mask layer's name if only store valid values.
 
CONST_CHARS STATS_RS_MEAN = "MEAN"
 Valid cell number.
 
CONST_CHARS STATS_RS_MIN = "MIN"
 Mean value.
 
CONST_CHARS STATS_RS_MAX = "MAX"
 Minimum value.
 
CONST_CHARS STATS_RS_STD = "STD"
 Maximum value.
 
CONST_CHARS STATS_RS_RANGE = "RANGE"
 Standard derivation value.
 
CONST_CHARS ASCIIExtension = "asc"
 Range value.
 
CONST_CHARS GTiffExtension = "tif"
 ASCII extension.
 

Detailed Description

Raster class to handle various raster data.

Enumeration Type Documentation

◆ RasterDataType

Coordinate pair.

Raster data types follows GDALDataType

Enumerator
RDT_Unknown 

GDT_Unknown.

RDT_UInt8 

GDT_Byte.

RDT_Int8 

GDT_Int8, GDAL>=3.7.

RDT_UInt16 

GDT_UInt16.

RDT_Int16 

GDT_Int16.

RDT_UInt32 

GDT_UInt32.

RDT_Int32 

GDT_Int32.

RDT_UInt64 

GDT_UInt64, GDAL>=3.5.

RDT_Int64 

GDT_Int64, GDAL>=3.5.

RDT_Float 

GDT_Float32.

RDT_Double 

GDT_Float64.

Function Documentation

◆ CopyHeader()

void ccgl::data_raster::CopyHeader ( const STRDBL_MAP refers,
STRDBL_MAP dst 
)

Copy header information from one to another.

Parameters
[in]refersReference header
[in]dstDestination header

◆ RasterDataTypeToString()

string ccgl::data_raster::RasterDataTypeToString ( int  type)

Common functions independent to clsRasterData.

Convert RasterDataType to string

◆ ReadAscFile()

template<typename T >
bool ccgl::data_raster::ReadAscFile ( const string &  filename,
STRDBL_MAP header,
T *&  values 
)

Read raster data from ASC file, the simply usage.

Parameters
[in]filenameFull path of ASC raster file
[out]headerRaster header information
[out]valuesAll raster values in 1d-array including NODATA_VALUE
Returns
true if read successfully, otherwise return false.

◆ ReadGridFsFile()

template<typename T >
bool ccgl::data_raster::ReadGridFsFile ( MongoGridFs gfs,
const string &  filename,
T *&  data,
STRDBL_MAP header,
STRING_MAP header_str,
const STRING_MAP opts 
)

Read GridFs file from MongoDB.

Parameters
[in]gfsMongoGridFs pointer
[in]filenameGridFs filename
[out]dataData stored in GridFs file
[out]headerHeader information
[out]header_strHeader information in strings
[in]optsOptional key-value stored in metadata, used to filter GridFs file

◆ ReadRasterFileByGdal()

template<typename T >
bool ccgl::data_raster::ReadRasterFileByGdal ( const string &  filename,
STRDBL_MAP header,
T *&  values,
RasterDataType in_type,
string &  srs 
)

Read single raster file by GDAL.

Parameters
[in]filenameFull path of raster data
[out]headerRaster header information
[out]valuesRaster data matrix
[out]in_typeRaster data type
[out]srsSRS of input raster data as string
Returns
true if read successfully, otherwise return false.

◆ WriteAscHeaders()

bool ccgl::data_raster::WriteAscHeaders ( const string &  filename,
const STRDBL_MAP header 
)

Write raster header information into a ASC file.

If the file exists, delete it first.

Parameters
[in]filenameASC full file path
[in]headerheader information

◆ WriteRasterToFile()

template<typename T >
bool ccgl::data_raster::WriteRasterToFile ( const string &  filename,
const STRDBL_MAP header,
const STRING_MAP opts,
T *  values 
)

Write single raster file, if the file exists, delete it first.

Parameters
[in]filenameoutput full file path
[in]headerheader information
[in]optsOptions, e.g., srs: Coordinate system string
[in]valuesraster data array

◆ WriteSingleAsc()

template<typename T >
bool ccgl::data_raster::WriteSingleAsc ( const string &  filename,
const STRDBL_MAP header,
T *  values 
)

Write raster data as a single ASC file.

If the file exists, delete it first.

Parameters
[in]filenameASC full file path
[in]headerheader information
[in]valuesraster data array

◆ WriteSingleGeotiff()

template<typename T >
bool ccgl::data_raster::WriteSingleGeotiff ( const string &  filename,
const STRDBL_MAP header,
const STRING_MAP opts,
T *  values 
)

Write single geotiff file If the file exists, delete it first.

Parameters
[in]filenamestring, output ASC file path
[in]headerheader information
[in]optsOptions, e.g., srs - Coordinate system string
[in]valuesraster data array

◆ WriteStreamDataAsGridfs()

template<typename T >
bool ccgl::data_raster::WriteStreamDataAsGridfs ( MongoGridFs gfs,
const string &  filename,
STRDBL_MAP header,
T *  values,
const int  datalength,
const STRING_MAP opts = STRING_MAP() 
)

Write array data (both valid and full-sized raster data) as GridFS file.

If the file exists, delete it first.

Parameters
[in]gfsGridFs of MongoDB
[in]filenameGridFS file name
[in]headerheader information
[in]valuesfloat raster data array
[in]datalengthLength of data
[in]opts(optional) Key-value map for user-specific metadata