26 #include "imageclasses/ImgWriterGdal.h" 27 #include "imageclasses/ImgReaderGdal.h" 28 #include "imageclasses/ImgReaderOgr.h" 29 #include "base/Optionpk.h" 30 #include "algorithms/Egcs.h" 101 int main(
int argc,
char *argv[])
103 Optionpk<string> input_opt(
"i",
"input",
"Input image file(s). If input contains multiple images, a multi-band output is created");
105 Optionpk<string> projection_opt(
"a_srs",
"a_srs",
"Override the projection for the output file (leave blank to copy from input file, use epsg:3035 to use European projection and force to European grid");
107 Optionpk<string> extent_opt(
"e",
"extent",
"get boundary from extent from polygons in vector file");
108 Optionpk<bool> cut_opt(
"cut",
"crop_to_cutline",
"Crop the extent of the target dataset to the extent of the cutline.",
false);
109 Optionpk<string> eoption_opt(
"eo",
"eo",
"special extent options controlling rasterization: ATTRIBUTE|CHUNKYSIZE|ALL_TOUCHED|BURN_VALUE_FROM|MERGE_ALG, e.g., -eo ATTRIBUTE=fieldname");
110 Optionpk<string> mask_opt(
"m",
"mask",
"Use the the specified file as a validity mask (0 is nodata).");
111 Optionpk<float> msknodata_opt(
"msknodata",
"msknodata",
"Mask value not to consider for crop.", 0);
112 Optionpk<short> mskband_opt(
"mskband",
"mskband",
"Mask band to read (0 indexed)", 0);
113 Optionpk<double> ulx_opt(
"ulx",
"ulx",
"Upper left x value bounding box", 0.0);
114 Optionpk<double> uly_opt(
"uly",
"uly",
"Upper left y value bounding box", 0.0);
115 Optionpk<double> lrx_opt(
"lrx",
"lrx",
"Lower right x value bounding box", 0.0);
116 Optionpk<double> lry_opt(
"lry",
"lry",
"Lower right y value bounding box", 0.0);
117 Optionpk<double> dx_opt(
"dx",
"dx",
"Output resolution in x (in meter) (empty: keep original resolution)");
118 Optionpk<double> dy_opt(
"dy",
"dy",
"Output resolution in y (in meter) (empty: keep original resolution)");
119 Optionpk<double> cx_opt(
"x",
"x",
"x-coordinate of image center to crop (in meter)");
120 Optionpk<double> cy_opt(
"y",
"y",
"y-coordinate of image center to crop (in meter)");
123 Optionpk<int> ns_opt(
"ns",
"ns",
"number of samples to crop (in pixels)");
124 Optionpk<int> nl_opt(
"nl",
"nl",
"number of lines to crop (in pixels)");
128 Optionpk<double> autoscale_opt(
"as",
"autoscale",
"scale output to min and max, e.g., --autoscale 0 --autoscale 255");
130 Optionpk<double> offset_opt(
"offset",
"offset",
"output=scale*input+offset");
131 Optionpk<string> otype_opt(
"ot",
"otype",
"Data type for output image ({Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFloat64}). Empty string: inherit type from input image",
"");
132 Optionpk<string> oformat_opt(
"of",
"oformat",
"Output image format (see also gdal_translate).",
"GTiff");
133 Optionpk<string> option_opt(
"co",
"co",
"Creation option for output file. Multiple options can be specified.");
134 Optionpk<string> colorTable_opt(
"ct",
"ct",
"color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid)");
135 Optionpk<double> nodata_opt(
"nodata",
"nodata",
"Nodata value to put in image if out of bounds.");
136 Optionpk<string> resample_opt(
"r",
"resampling-method",
"Resampling method (near: nearest neighbor, bilinear: bi-linear interpolation).",
"near");
137 Optionpk<string> description_opt(
"d",
"description",
"Set image description");
138 Optionpk<bool> align_opt(
"align",
"align",
"Align output bounding box to input image",
false);
141 extent_opt.setHide(1);
143 eoption_opt.setHide(1);
144 bstart_opt.setHide(1);
147 msknodata_opt.setHide(1);
148 mskband_opt.setHide(1);
149 option_opt.setHide(1);
156 scale_opt.setHide(1);
157 offset_opt.setHide(1);
158 nodata_opt.setHide(1);
159 description_opt.setHide(1);
163 doProcess=input_opt.retrieveOption(argc,argv);
164 output_opt.retrieveOption(argc,argv);
165 projection_opt.retrieveOption(argc,argv);
166 ulx_opt.retrieveOption(argc,argv);
167 uly_opt.retrieveOption(argc,argv);
168 lrx_opt.retrieveOption(argc,argv);
169 lry_opt.retrieveOption(argc,argv);
170 band_opt.retrieveOption(argc,argv);
171 bstart_opt.retrieveOption(argc,argv);
172 bend_opt.retrieveOption(argc,argv);
173 autoscale_opt.retrieveOption(argc,argv);
174 otype_opt.retrieveOption(argc,argv);
175 oformat_opt.retrieveOption(argc,argv);
176 colorTable_opt.retrieveOption(argc,argv);
177 dx_opt.retrieveOption(argc,argv);
178 dy_opt.retrieveOption(argc,argv);
179 resample_opt.retrieveOption(argc,argv);
180 extent_opt.retrieveOption(argc,argv);
181 cut_opt.retrieveOption(argc,argv);
182 eoption_opt.retrieveOption(argc,argv);
183 mask_opt.retrieveOption(argc,argv);
184 msknodata_opt.retrieveOption(argc,argv);
185 mskband_opt.retrieveOption(argc,argv);
186 option_opt.retrieveOption(argc,argv);
187 cx_opt.retrieveOption(argc,argv);
188 cy_opt.retrieveOption(argc,argv);
189 nx_opt.retrieveOption(argc,argv);
190 ny_opt.retrieveOption(argc,argv);
191 ns_opt.retrieveOption(argc,argv);
192 nl_opt.retrieveOption(argc,argv);
193 scale_opt.retrieveOption(argc,argv);
194 offset_opt.retrieveOption(argc,argv);
195 nodata_opt.retrieveOption(argc,argv);
196 description_opt.retrieveOption(argc,argv);
197 align_opt.retrieveOption(argc,argv);
198 verbose_opt.retrieveOption(argc,argv);
200 catch(
string predefinedString){
201 std::cout << predefinedString << std::endl;
205 cout << setprecision(12) <<
"--ulx=" << ulx_opt[0] <<
" --uly=" << uly_opt[0] <<
" --lrx=" << lrx_opt[0] <<
" --lry=" << lry_opt[0] << endl;
209 cout <<
"Usage: pkcrop -i input -o output" << endl;
211 std::cout <<
"short option -h shows basic options only, use long option --help to show all options" << std::endl;
214 if(input_opt.empty()){
215 std::cerr <<
"No input file provided (use option -i). Use --help for help information" << std::endl;
218 if(output_opt.empty()){
219 std::cerr <<
"No output file provided (use option -o). Use --help for help information" << std::endl;
223 float nodataValue=nodata_opt.size()? nodata_opt[0] : 0;
224 RESAMPLE theResample;
225 if(resample_opt[0]==
"near"){
228 cout <<
"resampling: nearest neighbor" << endl;
230 else if(resample_opt[0]==
"bilinear"){
231 theResample=BILINEAR;
233 cout <<
"resampling: bilinear interpolation" << endl;
236 std::cout <<
"Error: resampling method " << resample_opt[0] <<
" not supported" << std::endl;
240 const char* pszMessage;
241 void* pProgressArg=NULL;
242 GDALProgressFunc pfnProgress=GDALTermProgress;
244 pfnProgress(progress,pszMessage,pProgressArg);
258 if(bstart_opt.size()){
259 if(bend_opt.size()!=bstart_opt.size()){
260 string errorstring=
"Error: options for start and end band indexes must be provided as pairs, missing end band";
264 for(
int ipair=0;ipair<bstart_opt.size();++ipair){
265 if(bend_opt[ipair]<=bstart_opt[ipair]){
266 string errorstring=
"Error: index for end band must be smaller then start band";
269 for(
int iband=bstart_opt[ipair];iband<=bend_opt[ipair];++iband)
270 band_opt.push_back(iband);
275 cerr << error << std::endl;
280 string projectionString;
281 for(
int iimg=0;iimg<input_opt.size();++iimg){
283 imgReader.
open(input_opt[iimg],GA_ReadOnly);
286 cerr <<
"Error: could not open file " << input_opt[iimg] <<
": " << error << std::endl;
291 if(imgReader.
isGeoRef()&&projection_opt.empty())
303 ncropband+=band_opt.size();
309 GDALDataType theType=GDT_Unknown;
311 cout <<
"possible output data types: ";
312 for(
int iType = 0; iType < GDT_TypeCount; ++iType){
314 cout <<
" " << GDALGetDataTypeName((GDALDataType)iType);
315 if( GDALGetDataTypeName((GDALDataType)iType) != NULL
316 && EQUAL(GDALGetDataTypeName((GDALDataType)iType),
317 otype_opt[0].c_str()))
318 theType=(GDALDataType) iType;
322 if(theType==GDT_Unknown)
323 cout <<
"Unknown output pixel type: " << otype_opt[0] << endl;
325 cout <<
"Output pixel type: " << GDALGetDataTypeName(theType) << endl;
328 double cropulx=ulx_opt[0];
329 double cropuly=uly_opt[0];
330 double croplrx=lrx_opt[0];
331 double croplry=lry_opt[0];
335 if(extent_opt.size()){
340 for(
int iextent=0;iextent<extent_opt.size();++iextent){
342 extentReader.open(extent_opt[iextent]);
343 if(!(extentReader.getExtent(e_ulx,e_uly,e_lrx,e_lry))){
345 os <<
"Error: could not get extent from " << extent_opt[0] << endl;
350 cerr << error << std::endl;
369 extentReader.close();
371 if(croplrx>cropulx&&cropulx>ulx_opt[0])
373 if(croplrx>cropulx&&croplrx<lrx_opt[0])
375 if(cropuly>croplry&&cropuly<uly_opt[0])
377 if(croplry<cropuly&&croplry>lry_opt[0])
379 if(cut_opt.size()||eoption_opt.size())
380 extentReader.open(extent_opt[0]);
382 else if(cx_opt.size()&&cy_opt.size()&&nx_opt.size()&&ny_opt.size()){
383 ulx_opt[0]=cx_opt[0]-nx_opt[0]/2.0;
384 uly_opt[0]=(isGeoRef) ? cy_opt[0]+ny_opt[0]/2.0 : cy_opt[0]-ny_opt[0]/2.0;
385 lrx_opt[0]=cx_opt[0]+nx_opt[0]/2.0;
386 lry_opt[0]=(isGeoRef) ? cy_opt[0]-ny_opt[0]/2.0 : cy_opt[0]+ny_opt[0]/2.0;
396 else if(cx_opt.size()&&cy_opt.size()&&ns_opt.size()&&nl_opt.size()){
397 ulx_opt[0]=cx_opt[0]-ns_opt[0]*dx/2.0;
398 uly_opt[0]=(isGeoRef) ? cy_opt[0]+nl_opt[0]*dy/2.0 : cy_opt[0]-nl_opt[0]*dy/2.0;
399 lrx_opt[0]=cx_opt[0]+ns_opt[0]*dx/2.0;
400 lry_opt[0]=(isGeoRef) ? cy_opt[0]-nl_opt[0]*dy/2.0 : cy_opt[0]+nl_opt[0]*dy/2.0;
412 cout <<
"--ulx=" << ulx_opt[0] <<
" --uly=" << uly_opt[0] <<
" --lrx=" << lrx_opt[0] <<
" --lry=" << lry_opt[0] << endl;
418 if(extent_opt.size()&&(cut_opt[0]||eoption_opt.size())){
420 string errorString=
"Error: can only either mask or extent extent with cutline, not both";
424 ncropcol=abs(static_cast<int>(ceil((lrx_opt[0]-ulx_opt[0])/dx)));
425 ncroprow=abs(static_cast<int>(ceil((uly_opt[0]-lry_opt[0])/dy)));
427 maskWriter.
open(
"/vsimem/mask.tif",ncropcol,ncroprow,1,GDT_Float32,
"GTiff",option_opt);
436 if(projection_opt.size())
438 else if(projectionString.size())
441 vector<double> burnValues(1,1);
442 maskWriter.
rasterizeOgr(extentReader,burnValues,eoption_opt);
446 cerr << error << std::endl;
450 mask_opt.push_back(
"/vsimem/mask.tif");
453 if(mask_opt.size()==1){
456 maskReader.
open(mask_opt[0],GA_ReadOnly);
457 if(mskband_opt[0]>=maskReader.
nrOfBand()){
458 string errorString=
"Error: illegal mask band";
463 cerr << error << std::endl;
471 if(scale_opt.size()){
472 while(scale_opt.size()<band_opt.size())
473 scale_opt.push_back(scale_opt[0]);
475 if(offset_opt.size()){
476 while(offset_opt.size()<band_opt.size())
477 offset_opt.push_back(offset_opt[0]);
479 if(autoscale_opt.size()){
480 assert(autoscale_opt.size()%2==0);
487 for(
int iimg=0;iimg<input_opt.size();++iimg){
489 cout <<
"opening image " << input_opt[iimg] << endl;
491 imgReader.
open(input_opt[iimg],GA_ReadOnly);
494 cerr << error << std::endl;
498 if(theType==GDT_Unknown){
501 cout <<
"Using data type from input image: " << GDALGetDataTypeName(theType) << endl;
503 if(option_opt.findSubstring(
"INTERLEAVE=")==option_opt.end()){
504 string theInterleave=
"INTERLEAVE=";
506 option_opt.push_back(theInterleave);
515 cout <<
"size of " << input_opt[iimg] <<
": " << ncol <<
" cols, "<< nrow <<
" rows" << endl;
516 double uli,ulj,lri,lrj;
517 bool forceEUgrid=
false;
518 if(projection_opt.size())
519 forceEUgrid=(!(projection_opt[0].compare(
"EPSG:3035"))||!(projection_opt[0].compare(
"EPSG:3035"))||projection_opt[0].find(
"ETRS-LAEA")!=string::npos);
520 if(ulx_opt[0]>=lrx_opt[0]){
528 double magicX=1,magicY=1;
533 egcs.setLevel(egcs.res2level(dx));
534 egcs.force2grid(cropulx,cropuly,croplrx,croplry);
541 ncropcol=abs(static_cast<int>(ceil((croplrx-cropulx)/dx)));
542 ncroprow=abs(static_cast<int>(ceil((cropuly-croplry)/dy)));
545 double magicX=1,magicY=1;
554 egcs.setLevel(egcs.res2level(dx));
555 egcs.force2grid(cropulx,cropuly,croplrx,croplry);
557 else if(align_opt[0]){
558 if(cropulx>imgReader.
getUlx())
559 cropulx-=fmod(cropulx-imgReader.
getUlx(),dx);
560 else if(cropulx<imgReader.
getUlx())
561 cropulx+=fmod(imgReader.
getUlx()-cropulx,dx)-dx;
562 if(croplrx<imgReader.
getLrx())
563 croplrx+=fmod(imgReader.
getLrx()-croplrx,dx);
564 else if(croplrx>imgReader.
getLrx())
565 croplrx-=fmod(croplrx-imgReader.
getLrx(),dx)+dx;
566 if(croplry>imgReader.
getLry())
567 croplry-=fmod(croplry-imgReader.
getLry(),dy);
568 else if(croplry<imgReader.
getLry())
569 croplry+=fmod(imgReader.
getLry()-croplry,dy)-dy;
570 if(cropuly<imgReader.
getUly())
571 cropuly+=fmod(imgReader.
getUly()-cropuly,dy);
572 else if(cropuly>imgReader.
getUly())
573 cropuly-=fmod(cropuly-imgReader.
getUly(),dy)+dy;
578 ncropcol=abs(static_cast<int>(ceil((croplrx-cropulx)/dx)));
579 ncroprow=abs(static_cast<int>(ceil((cropuly-croplry)/dy)));
590 dcropcol=(lri-uli+1)/(dx/deltaX);
591 dcroprow=(lrj-ulj+1)/(dy/deltaY);
594 cout <<
"cropulx: " << cropulx << endl;
595 cout <<
"cropuly: " << cropuly << endl;
596 cout <<
"croplrx: " << croplrx << endl;
597 cout <<
"croplry: " << croplry << endl;
598 cout <<
"ncropcol: " << ncropcol << endl;
599 cout <<
"ncroprow: " << ncroprow << endl;
600 cout <<
"cropulx+ncropcol*dx: " << cropulx+ncropcol*dx << endl;
601 cout <<
"cropuly-ncroprow*dy: " << cropuly-ncroprow*dy << endl;
602 cout <<
"upper left column of input image: " << uli << endl;
603 cout <<
"upper left row of input image: " << ulj << endl;
604 cout <<
"lower right column of input image: " << lri << endl;
605 cout <<
"lower right row of input image: " << lrj << endl;
606 cout <<
"new number of cols: " << ncropcol << endl;
607 cout <<
"new number of rows: " << ncroprow << endl;
608 cout <<
"new number of bands: " << ncropband << endl;
621 if(oformat_opt.size())
622 imageType=oformat_opt[0];
624 imgWriter.
open(output_opt[0],ncropcol,ncroprow,ncropband,theType,imageType,option_opt);
625 if(nodata_opt.size()){
631 catch(
string errorstring){
632 cout << errorstring << endl;
635 if(description_opt.size())
643 gt[5]=(imgReader.
isGeoRef())? -dy : dy;
645 if(projection_opt.size()){
647 cout <<
"projection: " << projection_opt[0] << endl;
653 if(colorTable_opt.size()){
654 if(colorTable_opt[0]!=
"none")
666 else if(uli>=imgReader.
nrOfCol())
667 startCol=imgReader.
nrOfCol()-1;
670 else if(lri>=imgReader.
nrOfCol())
676 else if(ulj>=imgReader.
nrOfRow())
677 startRow=imgReader.
nrOfRow()-1;
680 else if(lrj>=imgReader.
nrOfRow())
683 int readncol=endCol-startCol+1;
685 vector<double> readBuffer;
686 int nband=(band_opt.size())?band_opt.size() : imgReader.
nrOfBand();
687 for(
int iband=0;iband<nband;++iband){
688 int readBand=(band_opt.size()>iband)?band_opt[iband]:iband;
690 cout <<
"extracting band " << readBand << endl;
691 pfnProgress(progress,pszMessage,pProgressArg);
695 if(autoscale_opt.size()){
697 imgReader.
getMinMax(static_cast<int>(startCol),static_cast<int>(endCol),static_cast<int>(startRow),static_cast<int>(endRow),readBand,theMin,theMax);
699 catch(
string errorString){
700 cout << errorString << endl;
703 cout <<
"minmax: " << theMin <<
", " << theMax << endl;
704 double theScale=(autoscale_opt[1]-autoscale_opt[0])/(theMax-theMin);
705 double theOffset=autoscale_opt[0]-theScale*theMin;
706 imgReader.
setScale(theScale,readBand);
710 if(scale_opt.size()){
711 if(scale_opt.size()>iband)
712 imgReader.
setScale(scale_opt[iband],readBand);
714 imgReader.
setScale(scale_opt[0],readBand);
716 if(offset_opt.size()){
717 if(offset_opt.size()>iband)
718 imgReader.
setOffset(offset_opt[iband],readBand);
720 imgReader.
setOffset(offset_opt[0],readBand);
728 for(
int irow=0;irow<imgWriter.
nrOfRow();++irow){
729 vector<float> lineMask;
735 imgReader.
geo2image(x,y,readCol,readRow);
736 vector<double> writeBuffer;
737 if(readRow<0||readRow>=imgReader.
nrOfRow()){
742 for(
int icol=0;icol<imgWriter.
nrOfCol();++icol)
743 writeBuffer.push_back(nodataValue);
747 if(endCol<imgReader.
nrOfCol()-1){
748 imgReader.
readData(readBuffer,startCol,endCol+1,readRow,readBand,theResample);
751 imgReader.
readData(readBuffer,startCol,endCol,readRow,readBand,theResample);
754 double oldRowMask=-1;
755 for(
int icol=0;icol<imgWriter.
nrOfCol();++icol){
758 imgReader.
geo2image(x,y,readCol,readRow);
759 if(readCol<0||readCol>=imgReader.
nrOfCol()){
765 writeBuffer.push_back(nodataValue);
777 imgWriter.
image2geo(icol,irow,geox,geoy);
778 maskReader.
geo2image(geox,geoy,colMask,rowMask);
779 colMask=
static_cast<int>(colMask);
780 rowMask=
static_cast<int>(rowMask);
781 if(rowMask>=0&&rowMask<maskReader.
nrOfRow()&&colMask>=0&&colMask<maskReader.
nrOfCol()){
782 if(static_cast<int>(rowMask)!=
static_cast<int>(oldRowMask)){
784 assert(rowMask>=0&&rowMask<maskReader.
nrOfRow());
786 maskReader.
readData(lineMask,static_cast<int>(rowMask),mskband_opt[0]);
788 catch(
string errorstring){
789 cerr << errorstring << endl;
793 cerr <<
"error caught" << std::endl;
798 for(
int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
799 if(lineMask[colMask]==msknodata_opt[ivalue]){
801 if(nodata_opt.size()>ivalue)
802 nodataValue=nodata_opt[ivalue];
808 writeBuffer.push_back(nodataValue);
812 lowerCol=readCol-0.5;
813 lowerCol=
static_cast<int>(lowerCol);
814 upperCol=readCol+0.5;
815 upperCol=
static_cast<int>(upperCol);
818 if(upperCol>=imgReader.
nrOfCol())
819 upperCol=imgReader.
nrOfCol()-1;
821 writeBuffer.push_back((readCol-0.5-lowerCol)*readBuffer[upperCol-startCol]+(1-readCol+0.5+lowerCol)*readBuffer[lowerCol-startCol]);
824 readCol=
static_cast<int>(readCol);
827 writeBuffer.push_back(readBuffer[readCol]);
834 catch(
string errorstring){
835 cout << errorstring << endl;
839 if(writeBuffer.size()!=imgWriter.
nrOfCol())
840 cout <<
"writeBuffer.size()=" << writeBuffer.size() <<
", imgWriter.nrOfCol()=" << imgWriter.
nrOfCol() << endl;
841 assert(writeBuffer.size()==imgWriter.
nrOfCol());
843 imgWriter.
writeData(writeBuffer,irow,writeBand);
845 catch(
string errorstring){
846 cout << errorstring << endl;
852 pfnProgress(progress,pszMessage,pProgressArg);
856 progress+=(imgWriter.
nrOfRow()*writeBand);
860 pfnProgress(progress,pszMessage,pProgressArg);
867 if(extent_opt.size()&&(cut_opt[0]||eoption_opt.size())){
868 extentReader.close();
double getLry() const
Get the lower right corner y (georeferenced) coordinate of this dataset.
void setOffset(double theOffset, int band=0)
Set offset for a specific band when writing the raster data values. The scaling and offset are applie...
double getUly() const
Get the upper left corner y (georeferenced) coordinate of this dataset.
void rasterizeOgr(ImgReaderOgr &ogrReader, const std::vector< double > &burnValues, const std::vector< std::string > &controlOptions=std::vector< std::string >(), const std::vector< std::string > &layernames=std::vector< std::string >())
Rasterize an OGR vector dataset using the gdal algorithm "GDALRasterizeLayers".
void setImageDescription(const std::string &imageDescription)
Set the image description (only for GeoTiff format: TIFFTAG_IMAGEDESCRIPTION)
bool geo2image(double x, double y, double &i, double &j) const
Convert georeferenced coordinates (x and y) to image coordinates (column and row) ...
CPLErr setProjectionProj4(const std::string &projection)
Set the projection for this dataset from user input (supports epsg:<number> format) ...
void close(void)
Set the memory (in MB) to cache a number of rows in memory.
int nrOfCol(void) const
Get the number of columns of this dataset.
bool getBoundingBox(double &ulx, double &uly, double &lrx, double &lry) const
Get the bounding box of this dataset in georeferenced coordinates.
void setColorTable(const std::string &filename, int band=0)
Set the color table using an (ASCII) file with 5 columns (value R G B alpha)
void readData(T &value, int col, int row, int band=0)
Read a single pixel cell value at a specific column and row for a specific band (all indices start co...
double getUlx() const
Get the upper left corner x (georeferenced) coordinate of this dataset.
int nrOfRow(void) const
Get the number of rows of this dataset.
bool image2geo(double i, double j, double &x, double &y) const
Convert image coordinates (column and row) to georeferenced coordinates (x and y) ...
GDALColorTable * getColorTable(int band=0) const
Get the GDAL color table for this dataset as an instance of the GDALColorTable class.
CPLErr setGeoTransform(double *gt)
Set the geotransform data for this dataset.
double getLrx() const
Get the lower right corner x (georeferenced) coordinate of this dataset.
bool isGeoRef() const
Is this dataset georeferenced (pixel size in y must be negative) ?
bool writeData(T &value, int col, int row, int band=0)
Write a single pixel cell value at a specific column and row for a specific band (all indices start c...
double getDeltaX(void) const
Get the pixel cell spacing in x.
double getDeltaY(void) const
Get the pixel cell spacing in y.
int setNoData(const std::vector< double > nodata)
Set the no data values of this dataset using a standard template library (stl) vector as input...
void getMinMax(int startCol, int endCol, int startRow, int endRow, int band, double &minValue, double &maxValue)
Get the minimum and maximum cell values for a specific band in a region of interest defined by startC...
void open(const std::string &filename, const ImgReaderGdal &imgSrc, const std::vector< std::string > &options=std::vector< std::string >())
Open an image for writing, copying image attributes from a source image. Image is directly written to...
std::string getProjection(void) const
Get the projection string (deprecated, use getProjectionRef instead)
GDALDataType getDataType(int band=0) const
Get the GDAL datatype for this dataset.
CPLErr setProjection(const std::string &projection)
Set the projection for this dataset in well known text (wkt) format.
void close(void)
Close the image.
void open(const std::string &filename, const GDALAccess &readMode=GA_ReadOnly)
Open an image.
int nrOfBand(void) const
Get the number of bands of this dataset.
void setScale(double theScale, int band=0)
Set scale for a specific band when writing the raster data values. The scaling and offset are applied...
std::string getInterleave() const
Get the band coding (interleave)