Geoscience Reference
In-Depth Information
#include
<string>
#include
<sstream>
#include
<iostream>
#include
<fstream>
#include
"gdal_priv.h"
using namespace
std;
int
main(
int
argc,
char
**argv) {
string stlsSrcImageFilename;//source raster dataset filename
string stlsCtFilename;//ASCII color table filename
try
{
//define error stream in case wrong arguments
ostringstream stlosError;
stlosError <<"usage: "<< argv[0] <<" -ct <asciiFilename>
→
<inputFilename>";
//loop over all command line arguments
for
(
int
i=1;i<argc;i++){
string stlsOption=argv[i];//convert to std::string
if
(stlsOption=="-h"||stlsOption=="--help")
throw
(stlosError.str());
else if
(stlsOption=="-ct"||stlsOption=="--color table"){
stlsCtFilename=argv[++i];
}
else if
(stlsOption.find('-')==0){
cerr <<"Error: unknown option "<< stlsOption << endl;
throw
(stlosError.str());
}
else if
(stlsSrcImageFilename.empty()){
stlsSrcImageFilename=argv[i];
}
else
{
cerr <<"Error: multiple raster files are not supported"<<
→
endl;
throw
(stlosError.str());
}
}
if
(stlsSrcImageFilename.empty()){
cerr <<"Error: no raster file provided"<< endl;
throw
(stlosError.str());
}
}
catch
(string stlsError){
cout << stlsError << endl;
exit(1);
}
//create color table here...
return
0;
}
The class provided by GDAL for color tables is
GDALColorTable
. Each line
in the color table corresponds to an
id
and an
entry
. The entry is a structure that
contains the color components. The interpretation of these components depends on
how the constructor of the class
GDALColorTable
was defined.
21
By default the
21
GPI_RGB
(red, green, blue and alpha),
GPI_Gray
(single gray scale component only),
GPI_CMYK
(cyan, magenta, yellow and black) and
GPI_HLS
(hue, lightness and saturation).
Search WWH ::
Custom Search