[Git][debian-gis-team/pktools][upstream] New upstream version 2.6.7.4+ds

Bas Couwenberg gitlab at salsa.debian.org
Sun Aug 19 15:12:28 BST 2018


Bas Couwenberg pushed to branch upstream at Debian GIS Project / pktools


Commits:
93a15c23 by Bas Couwenberg at 2018-08-19T12:26:09Z
New upstream version 2.6.7.4+ds
- - - - -


2 changed files:

- CMakeLists.txt
- src/apps/pkdiff.cc


Changes:

=====================================
CMakeLists.txt
=====================================
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,7 @@ set (PROJECT_SOURCE_DIR src)
 # The version number.
 set (PKTOOLS_VERSION_MAJOR 2)
 set (PKTOOLS_VERSION_MINOR 6)
-set (PKTOOLS_VERSION_PATCH 7.3)
+set (PKTOOLS_VERSION_PATCH 7.4)
 set (PKTOOLS_VERSION "${PKTOOLS_VERSION_MAJOR}.${PKTOOLS_VERSION_MINOR}.${PKTOOLS_VERSION_PATCH}")
 set (PKTOOLS_PACKAGE_VERSION "${PKTOOLS_VERSION_MAJOR}.${PKTOOLS_VERSION_MINOR}.${PKTOOLS_VERSION_PATCH}")
 set (PKTOOLS_PACKAGE_STRING "PKTOOLS ${PKTOOLS_VERSION_MAJOR}.${PKTOOLS_VERSION_MINOR}.${PKTOOLS_VERSION_PATCH}")
@@ -164,7 +164,7 @@ else()
 
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC ${PKTOOLS_COMMON_CXX_FLAGS}")
     if (CMAKE_COMPILER_IS_GNUCXX)
-      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
+      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
     endif()
 
   elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")


=====================================
src/apps/pkdiff.cc
=====================================
--- a/src/apps/pkdiff.cc
+++ b/src/apps/pkdiff.cc
@@ -39,15 +39,15 @@ along with pktools.  If not, see <http://www.gnu.org/licenses/>.
   Options: [-ln layer] [-b band] [-cm] [-lr attribute] [-c name -r value]* [-nodata value]* [-m mask] [-msknodata value]*
 
   Advanced options:
-       [-o output] [-f OGR format] [-lc attribute] [-bnd value [-hom] [-circ]] [-ct colortable] [-co NAME=VALUE]* 
+       [-o output] [-f OGR format] [-lc attribute] [-bnd value [-hom] [-circ]] [-ct colortable] [-co NAME=VALUE]*
 
 </code>
 
 \section pkdiff_description Description
 
-The utility pkdiff compares two datasets. The reference can either be a raster or a vector, but the input must be a raster dataset.  
-In case the reference is a raster dataset, a pixel by pixel comparison is performed. With no further options, the utility reports if the rasters are identical or different. If required, an output raster dataset can be written with a qualitative information per pixel: 0 (input=reference), 1 (input>reference) or 2 (input<reference). 
-If, however, the reference is a vector dataset, it must consist of point features. Polygon features are automatically converted to the centroid points before analyzing. 
+The utility pkdiff compares two datasets. The reference can either be a raster or a vector, but the input must be a raster dataset.
+In case the reference is a raster dataset, a pixel by pixel comparison is performed. With no further options, the utility reports if the rasters are identical or different. If required, an output raster dataset can be written with a qualitative information per pixel: 0 (input=reference), 1 (input>reference) or 2 (input<reference).
+If, however, the reference is a vector dataset, it must consist of point features. Polygon features are automatically converted to the centroid points before analyzing.
 
 A typical use of the utility is to assess the accuracy of an input raster land cover map, based on a reference vector dataset. The reference dataset must contain an attribute (label) for each class. A confusion matrix is produced if the option -cm|--confusion is set. Here too, an output dataset can be written, which will be a vector dataset in this case. It contains the reference feature points with the extracted data value of the raster input dataset as a new attribute.
 \section pkdiff_options Options
@@ -55,32 +55,32 @@ A typical use of the utility is to assess the accuracy of an input raster land c
  - short option `-h` shows basic options only, long option `--help` shows all options
 |short|long|type|default|description|
 |-----|----|----|-------|-----------|
- | i      | input                | std::string |       |Input raster dataset. | 
- | ref    | reference            | std::string |       |Reference (raster or vector) dataset | 
- | ln     | ln                   | std::string |       |Layer name(s) in sample. Leave empty to select all (for vector reference datasets only) | 
- | b      | band                 | short | 0     |Input (reference) raster band. Optionally, you can define different bands for input and reference bands respectively: -b 1 -b 0. | 
- | rmse   | rmse                 | bool | false |Report root mean squared error | 
- | reg    | reg                  | bool | false |Report linear regression (Input = c0+c1*Reference) | 
- | cm     | confusion            | bool | false |Create confusion matrix (to std out) | 
- | lr     | lref                 | std::string | label |Attribute name of the reference label (for vector reference datasets only) | 
- | c      | class                | std::string |       |List of class names. | 
- | r      | reclass              | short |       |List of class values (use same order as in classname option). | 
- | nodata | nodata               | double |       |No data value(s) in input or reference dataset are ignored | 
- | m      | mask                 | std::string |       |Use the first band of the specified file as a validity mask. Nodata values can be set with the option msknodata. | 
- | msknodata | msknodata            | double | 0     |Mask value(s) where image is invalid. Use negative value for valid data (example: use -t -1: if only -1 is valid value) | 
- | o      | output               | std::string |       |Output dataset (optional) | 
- | f      | f                    | std::string | SQLite |OGR format for output vector (for vector reference datasets only) | 
- | of     | oformat              | std::string | GTiff |Output image format (see also gdal_translate).| 
- | lc     | lclass               | std::string | class |Attribute name of the classified label (for vector reference datasets only) | 
- | cmf    | cmf                  | std::string | ascii |Format for confusion matrix (ascii or latex) | 
- | cmo    | cmo                  | std::string |       |Output file for confusion matrix | 
- | se95   | se95                 | bool | false |Report standard error for 95 confidence interval | 
- | bnd    | boundary             | short | 1     |Boundary for selecting the sample (for vector reference datasets only) | 
- | hom    | homogeneous          | bool | false |Only take regions with homogeneous boundary into account (for reference datasets only) | 
- | circ   | circular             | bool | false |Use circular boundary (for vector reference datasets only) | 
- | ct     | ct                   | std::string |       |Color table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid). | 
- | co     | co                   | std::string |       |Creation option for output file. Multiple options can be specified. | 
- |        | commission           | short | 2     |Value for commission errors: input label < reference label | 
+ | i      | input                | std::string |       |Input raster dataset. |
+ | ref    | reference            | std::string |       |Reference (raster or vector) dataset |
+ | ln     | ln                   | std::string |       |Layer name(s) in sample. Leave empty to select all (for vector reference datasets only) |
+ | b      | band                 | short | 0     |Input (reference) raster band. Optionally, you can define different bands for input and reference bands respectively: -b 1 -b 0. |
+ | rmse   | rmse                 | bool | false |Report root mean squared error |
+ | reg    | reg                  | bool | false |Report linear regression (Input = c0+c1*Reference) |
+ | cm     | confusion            | bool | false |Create confusion matrix (to std out) |
+ | lr     | lref                 | std::string | label |Attribute name of the reference label (for vector reference datasets only) |
+ | c      | class                | std::string |       |List of class names. |
+ | r      | reclass              | short |       |List of class values (use same order as in classname option). |
+ | nodata | nodata               | double |       |No data value(s) in input or reference dataset are ignored |
+ | m      | mask                 | std::string |       |Use the first band of the specified file as a validity mask. Nodata values can be set with the option msknodata. |
+ | msknodata | msknodata            | double | 0     |Mask value(s) where image is invalid. Use negative value for valid data (example: use -t -1: if only -1 is valid value) |
+ | o      | output               | std::string |       |Output dataset (optional) |
+ | f      | f                    | std::string | SQLite |OGR format for output vector (for vector reference datasets only) |
+ | of     | oformat              | std::string | GTiff |Output image format (see also gdal_translate).|
+ | lc     | lclass               | std::string | class |Attribute name of the classified label (for vector reference datasets only) |
+ | cmf    | cmf                  | std::string | ascii |Format for confusion matrix (ascii or latex) |
+ | cmo    | cmo                  | std::string |       |Output file for confusion matrix |
+ | se95   | se95                 | bool | false |Report standard error for 95 confidence interval |
+ | bnd    | boundary             | short | 1     |Boundary for selecting the sample (for vector reference datasets only) |
+ | hom    | homogeneous          | bool | false |Only take regions with homogeneous boundary into account (for reference datasets only) |
+ | circ   | circular             | bool | false |Use circular boundary (for vector reference datasets only) |
+ | ct     | ct                   | std::string |       |Color table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid). |
+ | co     | co                   | std::string |       |Creation option for output file. Multiple options can be specified. |
+ |        | commission           | short | 2     |Value for commission errors: input label < reference label |
 
 Usage: pkdiff -i input -ref reference
 
@@ -108,8 +108,8 @@ int main(int argc, char *argv[])
   Optionpk<string> cmoutput_opt("cmo","cmo","Output file for confusion matrix");
   Optionpk<bool> se95_opt("se95","se95","Report standard error for 95 confidence interval",false);
   Optionpk<string> labelref_opt("lr", "lref", "Attribute name of the reference label (for vector reference datasets only)", "label");
-  Optionpk<string> classname_opt("c", "class", "List of class names."); 
-  Optionpk<short> classvalue_opt("r", "reclass", "List of class values (use same order as in classname option)."); 
+  Optionpk<string> classname_opt("c", "class", "List of class names.");
+  Optionpk<short> classvalue_opt("r", "reclass", "List of class values (use same order as in classname option).");
   Optionpk<string> output_opt("o", "output", "Output dataset (optional)");
   Optionpk<string> ogrformat_opt("f", "f", "OGR format for output vector (for vector reference datasets only)","SQLite");
   Optionpk<string>  oformat_opt("of", "oformat", "Output image format (see also gdal_translate).","GTiff");
@@ -238,7 +238,7 @@ int main(int argc, char *argv[])
       inputReader.getRange(inputRange,band_opt[0]);
       inputReader.close();
     // }
-  
+
     for(int iflag=0;iflag<nodata_opt.size();++iflag){
       vector<short>::iterator fit;
       fit=find(inputRange.begin(),inputRange.end(),static_cast<short>(nodata_opt[iflag]));
@@ -281,18 +281,25 @@ int main(int argc, char *argv[])
       nvalidation[rc]=0;
     }
   }
-  
+
   bool isDifferent=false;
   bool refIsRaster=false;
 
   ImgReaderOgr referenceReaderOgr;
   try{
     referenceReaderOgr.open(reference_opt[0]);
+    double ulx,uly,lrx,lry;
+    if(!referenceReaderOgr.getExtent(ulx,uly,lrx,lry))
+      throw(std::string("Input is raster"));
     referenceReaderOgr.close();
+    if(verbose_opt[0])
+      std::cout << "reference is vector dataset" << std::endl;
   }
   catch(string errorString){
     //todo: sampleIsRaster will not work from GDAL 2.0!!?? (unification of driver for raster and vector datasets)
     refIsRaster=true;
+    if(verbose_opt[0])
+      std::cout << "reference is raster dataset" << std::endl;
   }
   const char* pszMessage;
   void* pProgressArg=NULL;
@@ -302,11 +309,11 @@ int main(int argc, char *argv[])
   if(!refIsRaster){
     for(int iinput=0;iinput<input_opt.size();++iinput){
       if(verbose_opt[0])
-	cout << "Processing input " << input_opt[iinput] << endl;
+        cout << "Processing input " << input_opt[iinput] << endl;
       if(output_opt.size())
         assert(reference_opt.size()==output_opt.size());
       for(int iref=0;iref<reference_opt.size();++iref){
-	cout << "reference " << reference_opt[iref] << endl;
+        cout << "reference " << reference_opt[iref] << endl;
         // assert(reference_opt[iref].find(".shp")!=string::npos);
         try{
           inputReader.open(input_opt[iinput]);//,imagicX_opt[0],imagicY_opt[0]);
@@ -325,336 +332,336 @@ int main(int argc, char *argv[])
           referenceRange=inputRange;
 
         ImgWriterOgr ogrWriter;
-	if(output_opt.size()){
-	  try{
-	    ogrWriter.open(output_opt[iref],ogrformat_opt[0]);
-	  }
-	  catch(string error){
-	    cerr << error << endl;
-	    exit(1);
-	  }
-	}
-	int nlayer=referenceReaderOgr.getDataSource()->GetLayerCount();
-	for(int ilayer=0;ilayer<nlayer;++ilayer){
-	  progress=0;
-	  OGRLayer *readLayer=referenceReaderOgr.getLayer(ilayer);
-	  //	  readLayer = referenceReaderOgr.getDataSource()->GetLayer(ilayer);
-	  string currentLayername=readLayer->GetName();
-	  if(layer_opt.size())
-	    if(find(layer_opt.begin(),layer_opt.end(),currentLayername)==layer_opt.end())
-	      continue;
-	  if(!verbose_opt[0])
-	    pfnProgress(progress,pszMessage,pProgressArg);
-	  else
-	    cout << "processing layer " << readLayer->GetName() << endl;
-
-	  readLayer->ResetReading();
-	  OGRLayer *writeLayer;
-	  if(output_opt.size()){
-	    if(verbose_opt[0])
-	      cout << "creating output vector file " << output_opt[0] << endl;
-	    // assert(output_opt[0].find(".shp")!=string::npos);
-	    char     **papszOptions=NULL;
-	    if(verbose_opt[0])
-	      cout << "creating layer: " << readLayer->GetName() << endl;
-	    // if(ogrWriter.createLayer(layername, referenceReaderOgr.getProjection(ilayer), referenceReaderOgr.getGeometryType(ilayer), papszOptions)==NULL)
-	    writeLayer=ogrWriter.createLayer(readLayer->GetName(), referenceReaderOgr.getProjection(ilayer), wkbPoint, papszOptions);
-	    assert(writeLayer);
-	    if(verbose_opt[0]){
-	      cout << "created layer" << endl;
-	      cout << "copy fields from " << reference_opt[iref] << endl;
-	    }
-	    ogrWriter.copyFields(referenceReaderOgr,ilayer,ilayer);
-	    //create extra field for classified label
-	    short theDim=boundary_opt[0];
-	    for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
-	      for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
-		if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
-		  continue;
-		ostringstream fs;
-		if(theDim>1)
-		  fs << labelclass_opt[0] << "_" << windowJ << "_" << windowI;
-		else
-		  fs << labelclass_opt[0];
-		if(verbose_opt[0])
-		  cout << "creating field " << fs.str() << endl;
-		ogrWriter.createField(fs.str(),OFTInteger,ilayer);
-	      }
-	    }
-	  }
-	  OGRFeature *readFeature;
-	  OGRFeature *writeFeature;
-	  int isample=0;
-	  unsigned int nfeatureInLayer=readLayer->GetFeatureCount();
-	  unsigned int ifeature=0;
-	  while( (readFeature = readLayer->GetNextFeature()) != NULL ){
-	    if(verbose_opt[0])
-	      cout << "sample " << ++isample << endl;
-	    //get x and y from readFeature
-	    double x,y;
-	    OGRGeometry *poGeometry;
-	    OGRPoint centroidPoint;
-	    OGRPoint *poPoint;
-	    poGeometry = readFeature->GetGeometryRef();
-	    // assert( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPoint );
-	    if(poGeometry==NULL)
-	      continue;
-	    else if(wkbFlatten(poGeometry->getGeometryType()) == wkbMultiPolygon){
-	      OGRMultiPolygon readPolygon = *((OGRMultiPolygon *) poGeometry);
-	      readPolygon = *((OGRMultiPolygon *) poGeometry);
-	      readPolygon.Centroid(&centroidPoint);
-	      poPoint=¢roidPoint;
-	    }
-	    else if(wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon){
-	      OGRPolygon readPolygon=*((OGRPolygon *) poGeometry);
-	      readPolygon.Centroid(&centroidPoint);
-	      poPoint=¢roidPoint;
-	    }
-	    else if(wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
-	      poPoint = (OGRPoint *) poGeometry;
-	    else{
-	      std::cerr << "Warning: skipping feature (not of type point or polygon)" << std::endl;
-	      continue;
-	    }
-	    x=poPoint->getX();
-	    y=poPoint->getY();
-	    double inputValue;
-	    vector<double> inputValues;
-	    bool isHomogeneous=true;
-	    short maskValue;
-	    short outputValue;
-	    //read referenceValue from feature
-	    unsigned short referenceValue;
-	    string referenceClassName;
-	    if(classValueMap.size()){
-	      referenceClassName=readFeature->GetFieldAsString(readFeature->GetFieldIndex(labelref_opt[0].c_str()));
-	      referenceValue=classValueMap[referenceClassName];
-	    }
-	    else
-	      referenceValue=readFeature->GetFieldAsInteger(readFeature->GetFieldIndex(labelref_opt[0].c_str()));
-	    if(verbose_opt[0])
-	      cout << "reference value: " << referenceValue << endl;
-	    
-	    bool pixelFlagged=false;
-	    bool maskFlagged=false;
-	    for(int iflag=0;iflag<nodata_opt.size();++iflag){
-	      if(referenceValue==nodata_opt[iflag])
-		pixelFlagged=true;
-	    }
-	    if(pixelFlagged)
-	      continue;
-	    double i_centre,j_centre;
-	    //input reader is georeferenced!
-	    inputReader.geo2image(x,y,i_centre,j_centre);
-	    //       else{
-	    //         i_centre=x;
-	    //         j_centre=y;
-	    //       }
-	    //nearest neighbour
-	    j_centre=static_cast<int>(j_centre);
-	    i_centre=static_cast<int>(i_centre);
-	    //check if j_centre is out of bounds
-	    if(static_cast<int>(j_centre)<0||static_cast<int>(j_centre)>=inputReader.nrOfRow())
-	      continue;
-	    //check if i_centre is out of bounds
-	    if(static_cast<int>(i_centre)<0||static_cast<int>(i_centre)>=inputReader.nrOfCol())
-	      continue;
-
-	    if(output_opt.size()){
-	      writeFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
-	      assert(readFeature);
-	      int nfield=readFeature->GetFieldCount();
-	      writeFeature->SetGeometry(poPoint);
-	      if(verbose_opt[0])
-	      	cout << "copying fields from " << reference_opt[0] << endl;
-	      assert(readFeature);
-	      assert(writeFeature);
-	      vector<int> panMap(nfield);
-	      vector<int>::iterator panit=panMap.begin();
-	      for(int ifield=0;ifield<nfield;++ifield)
-	      	panMap[ifield]=ifield;
-	      writeFeature->SetFieldsFrom(readFeature,&(panMap[0]));
-	      // if(writeFeature->SetFrom(readFeature)!= OGRERR_NONE)
-	      // 	cerr << "writing feature failed" << endl;
-	      // if(verbose_opt[0])
-	      // 	cout << "feature written" << endl;
-	    }
-	    bool windowAllFlagged=true;
-	    bool windowHasFlag=false;
-	    short theDim=boundary_opt[0];
-	    for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
-	      for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
-		if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
-		  continue;
-		int j=j_centre+windowJ;
-		//check if j is out of bounds
-		if(static_cast<int>(j)<0||static_cast<int>(j)>=inputReader.nrOfRow())
-		  continue;
-		int i=i_centre+windowI;
-		//check if i is out of bounds
-		if(static_cast<int>(i)<0||static_cast<int>(i)>=inputReader.nrOfCol())
-		  continue;
-		if(verbose_opt[0])
-		  cout << setprecision(12) << "reading image value at x,y " << x << "," << y << " (" << i << "," << j << "), ";
-		inputReader.readData(inputValue,i,j,band_opt[0]);
-		inputValues.push_back(inputValue);
-		if(inputValues.back()!=*(inputValues.begin()))
-		  isHomogeneous=false;
-		if(verbose_opt[0])
-		  cout << "input value: " << inputValue << endl;
-		pixelFlagged=false;
-		for(int iflag=0;iflag<nodata_opt.size();++iflag){
-		  if(inputValue==nodata_opt[iflag]){
-		    pixelFlagged=true;
-		    break;
-		  }
-		}
-		maskFlagged=false;//(msknodata_opt[ivalue]>=0)?false:true;
-		if(mask_opt.size()){
-		  maskReader.readData(maskValue,i,j,0);
-		  for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-		    if(msknodata_opt[ivalue]>=0){//values set in msknodata_opt are invalid
-		      if(maskValue==msknodata_opt[ivalue]){
-			maskFlagged=true;
-			break;
-		      }
-		    }
-		    else{//only values set in msknodata_opt are valid
-		      if(maskValue!=-msknodata_opt[ivalue])
-			maskFlagged=true;
-		      else{
-			maskFlagged=false;
-			break;
-		      }
-		    }
-		  }
-		}
-		pixelFlagged=pixelFlagged||maskFlagged;
-		if(pixelFlagged)
-		  windowHasFlag=true;
-		else
-		  windowAllFlagged=false;//at least one good pixel in neighborhood
-	      }
-	    }
-	    //at this point we know the values for the entire window
-
-	    if(homogeneous_opt[0]){//only centre pixel
-	      int j=j_centre;
-	      int i=i_centre;
-	      //flag if not all pixels are homogeneous or if at least one pixel flagged
-          
-	      if(!windowHasFlag&&isHomogeneous){
-		if(output_opt.size())
-		  writeFeature->SetField(labelclass_opt[0].c_str(),static_cast<int>(inputValue));
-		if(confusion_opt[0]){
-		  ++ntotalValidation;
-		  if(classValueMap.size()){
-		    assert(inputValue<nameVector.size());
-		    string className=nameVector[static_cast<unsigned short>(inputValue)];
-		    cm.incrementResult(type2string<short>(classValueMap[referenceClassName]),type2string<short>(classValueMap[className]),1);
-		  }
-		  else{
-		    int rc=distance(referenceRange.begin(),find(referenceRange.begin(),referenceRange.end(),static_cast<unsigned short>(referenceValue)));
-		    int ic=distance(inputRange.begin(),find(inputRange.begin(),inputRange.end(),static_cast<unsigned short>(inputValue)));
-		    assert(rc<nclass);
-		    assert(ic<nclass);
-		    ++nvalidation[rc];
-		    ++resultClass[rc][ic];
-		    if(verbose_opt[0]>1)
-		      cout << "increment: " << rc << " " << referenceRange[rc] << " " << ic << " " << inputRange[ic] << endl;
-		    cm.incrementResult(cm.getClass(rc),cm.getClass(ic),1);
-		  }
-		}
-		if(inputValue==referenceValue){//correct
-		  outputValue=valueE_opt[0];
-		  if(nodata_opt.size()){
-		    if(valueE_opt[0]==nodata_opt[0])
-		      outputValue=inputValue;
-		  }
-		}
-		else if(inputValue>referenceValue)//1=forest,2=non-forest
-		  outputValue=valueO_opt[0];//omission error
-		else
-		  outputValue=valueC_opt[0];//commission error
-	      }
-	    }
-	    else{
-	      for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
-		for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
-		  if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
-		    continue;
-		  int j=j_centre+windowJ;
-		  //check if j is out of bounds
-		  if(static_cast<int>(j)<0||static_cast<int>(j)>=inputReader.nrOfRow())
-		    continue;
-		  int i=i_centre+windowI;
-		  //check if i is out of bounds
-		  if(static_cast<int>(i)<0||static_cast<int>(i)>=inputReader.nrOfCol())
-		    continue;
-		  if(!windowAllFlagged){
-		    ostringstream fs;
-		    if(theDim>1)
-		      fs << labelclass_opt[0] << "_" << windowJ << "_" << windowI;
-		    else
-		      fs << labelclass_opt[0];
-		    if(output_opt.size())
-		      writeFeature->SetField(fs.str().c_str(),inputValue);
-		    if(!windowJ&&!windowI){//centre pixel
-		      if(confusion_opt[0]){
-			++ntotalValidation;
-			if(classValueMap.size()){
-			  assert(inputValue<nameVector.size());
-			  string className=nameVector[static_cast<unsigned short>(inputValue)];
-			  cm.incrementResult(type2string<short>(classValueMap[referenceClassName]),type2string<short>(classValueMap[className]),1);
-			}
-			else{
-			  int rc=distance(referenceRange.begin(),find(referenceRange.begin(),referenceRange.end(),static_cast<unsigned short>(referenceValue)));
-			  int ic=distance(inputRange.begin(),find(inputRange.begin(),inputRange.end(),static_cast<unsigned short>(inputValue)));
-			  if(rc>=nclass)
-			    continue;
-			  if(ic>=nclass)
-			    continue;
-			  // assert(rc<nclass);
-			  // assert(ic<nclass);
-			  ++nvalidation[rc];
-			  ++resultClass[rc][ic];
-			  if(verbose_opt[0]>1)
-			    cout << "increment: " << rc << " " << referenceRange[rc] << " " << ic << " " << inputRange[ic] << endl;
-			  cm.incrementResult(cm.getClass(rc),cm.getClass(ic),1);
-			}
-		      }
-		      if(inputValue==referenceValue){//correct
-			outputValue=valueE_opt[0];
-			if(nodata_opt.size()){
-			  if(valueE_opt[0]==nodata_opt[0])
-			    outputValue=inputValue;
-			}
-		      }
-		      else if(inputValue>referenceValue)//1=forest,2=non-forest
-			outputValue=valueO_opt[0];//omission error
-		      else
-			outputValue=valueC_opt[0];//commission error
-		    }
-		  }
-		}
-	      }
-	    }
-	    if(output_opt.size()){
-	      if(!windowAllFlagged){
-		if(verbose_opt[0])
-		  cout << "creating feature" << endl;
-		if(writeLayer->CreateFeature( writeFeature ) != OGRERR_NONE ){
-		  string errorString="Failed to create feature in OGR vector file";
-		  throw(errorString);
-		}
-	      }
-	      OGRFeature::DestroyFeature( writeFeature );
-	    }
-	    ++ifeature;
-	    progress=static_cast<float>(ifeature+1)/nfeatureInLayer;
-	    pfnProgress(progress,pszMessage,pProgressArg);
-	  }//next feature
-	}//next layer
+        if(output_opt.size()){
+          try{
+            ogrWriter.open(output_opt[iref],ogrformat_opt[0]);
+          }
+          catch(string error){
+            cerr << error << endl;
+            exit(1);
+          }
+        }
+        int nlayer=referenceReaderOgr.getDataSource()->GetLayerCount();
+        for(int ilayer=0;ilayer<nlayer;++ilayer){
+          progress=0;
+          OGRLayer *readLayer=referenceReaderOgr.getLayer(ilayer);
+          //    readLayer = referenceReaderOgr.getDataSource()->GetLayer(ilayer);
+          string currentLayername=readLayer->GetName();
+          if(layer_opt.size())
+            if(find(layer_opt.begin(),layer_opt.end(),currentLayername)==layer_opt.end())
+              continue;
+          if(!verbose_opt[0])
+            pfnProgress(progress,pszMessage,pProgressArg);
+          else
+            cout << "processing layer " << readLayer->GetName() << endl;
+
+          readLayer->ResetReading();
+          OGRLayer *writeLayer;
+          if(output_opt.size()){
+            if(verbose_opt[0])
+              cout << "creating output vector file " << output_opt[0] << endl;
+            // assert(output_opt[0].find(".shp")!=string::npos);
+            char     **papszOptions=NULL;
+            if(verbose_opt[0])
+              cout << "creating layer: " << readLayer->GetName() << endl;
+            // if(ogrWriter.createLayer(layername, referenceReaderOgr.getProjection(ilayer), referenceReaderOgr.getGeometryType(ilayer), papszOptions)==NULL)
+            writeLayer=ogrWriter.createLayer(readLayer->GetName(), referenceReaderOgr.getProjection(ilayer), wkbPoint, papszOptions);
+            assert(writeLayer);
+            if(verbose_opt[0]){
+              cout << "created layer" << endl;
+              cout << "copy fields from " << reference_opt[iref] << endl;
+            }
+            ogrWriter.copyFields(referenceReaderOgr,ilayer,ilayer);
+            //create extra field for classified label
+            short theDim=boundary_opt[0];
+            for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
+              for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
+                if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
+                  continue;
+                ostringstream fs;
+                if(theDim>1)
+                  fs << labelclass_opt[0] << "_" << windowJ << "_" << windowI;
+                else
+                  fs << labelclass_opt[0];
+                if(verbose_opt[0])
+                  cout << "creating field " << fs.str() << endl;
+                ogrWriter.createField(fs.str(),OFTInteger,ilayer);
+              }
+            }
+          }
+          OGRFeature *readFeature;
+          OGRFeature *writeFeature;
+          int isample=0;
+          unsigned int nfeatureInLayer=readLayer->GetFeatureCount();
+          unsigned int ifeature=0;
+          while( (readFeature = readLayer->GetNextFeature()) != NULL ){
+            if(verbose_opt[0])
+              cout << "sample " << ++isample << endl;
+            //get x and y from readFeature
+            double x,y;
+            OGRGeometry *poGeometry;
+            OGRPoint centroidPoint;
+            OGRPoint *poPoint;
+            poGeometry = readFeature->GetGeometryRef();
+            // assert( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPoint );
+            if(poGeometry==NULL)
+              continue;
+            else if(wkbFlatten(poGeometry->getGeometryType()) == wkbMultiPolygon){
+              OGRMultiPolygon readPolygon = *((OGRMultiPolygon *) poGeometry);
+              readPolygon = *((OGRMultiPolygon *) poGeometry);
+              readPolygon.Centroid(&centroidPoint);
+              poPoint=¢roidPoint;
+            }
+            else if(wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon){
+              OGRPolygon readPolygon=*((OGRPolygon *) poGeometry);
+              readPolygon.Centroid(&centroidPoint);
+              poPoint=¢roidPoint;
+            }
+            else if(wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
+              poPoint = (OGRPoint *) poGeometry;
+            else{
+              std::cerr << "Warning: skipping feature (not of type point or polygon)" << std::endl;
+              continue;
+            }
+            x=poPoint->getX();
+            y=poPoint->getY();
+            double inputValue;
+            vector<double> inputValues;
+            bool isHomogeneous=true;
+            short maskValue;
+            short outputValue;
+            //read referenceValue from feature
+            unsigned short referenceValue;
+            string referenceClassName;
+            if(classValueMap.size()){
+              referenceClassName=readFeature->GetFieldAsString(readFeature->GetFieldIndex(labelref_opt[0].c_str()));
+              referenceValue=classValueMap[referenceClassName];
+            }
+            else
+              referenceValue=readFeature->GetFieldAsInteger(readFeature->GetFieldIndex(labelref_opt[0].c_str()));
+            if(verbose_opt[0])
+              cout << "reference value: " << referenceValue << endl;
+
+            bool pixelFlagged=false;
+            bool maskFlagged=false;
+            for(int iflag=0;iflag<nodata_opt.size();++iflag){
+              if(referenceValue==nodata_opt[iflag])
+                pixelFlagged=true;
+            }
+            if(pixelFlagged)
+              continue;
+            double i_centre,j_centre;
+            //input reader is georeferenced!
+            inputReader.geo2image(x,y,i_centre,j_centre);
+            //       else{
+            //         i_centre=x;
+            //         j_centre=y;
+            //       }
+            //nearest neighbour
+            j_centre=static_cast<int>(j_centre);
+            i_centre=static_cast<int>(i_centre);
+            //check if j_centre is out of bounds
+            if(static_cast<int>(j_centre)<0||static_cast<int>(j_centre)>=inputReader.nrOfRow())
+              continue;
+            //check if i_centre is out of bounds
+            if(static_cast<int>(i_centre)<0||static_cast<int>(i_centre)>=inputReader.nrOfCol())
+              continue;
+
+            if(output_opt.size()){
+              writeFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
+              assert(readFeature);
+              int nfield=readFeature->GetFieldCount();
+              writeFeature->SetGeometry(poPoint);
+              if(verbose_opt[0])
+                cout << "copying fields from " << reference_opt[0] << endl;
+              assert(readFeature);
+              assert(writeFeature);
+              vector<int> panMap(nfield);
+              vector<int>::iterator panit=panMap.begin();
+              for(int ifield=0;ifield<nfield;++ifield)
+                panMap[ifield]=ifield;
+              writeFeature->SetFieldsFrom(readFeature,&(panMap[0]));
+              // if(writeFeature->SetFrom(readFeature)!= OGRERR_NONE)
+              //  cerr << "writing feature failed" << endl;
+              // if(verbose_opt[0])
+              //  cout << "feature written" << endl;
+            }
+            bool windowAllFlagged=true;
+            bool windowHasFlag=false;
+            short theDim=boundary_opt[0];
+            for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
+              for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
+                if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
+                  continue;
+                int j=j_centre+windowJ;
+                //check if j is out of bounds
+                if(static_cast<int>(j)<0||static_cast<int>(j)>=inputReader.nrOfRow())
+                  continue;
+                int i=i_centre+windowI;
+                //check if i is out of bounds
+                if(static_cast<int>(i)<0||static_cast<int>(i)>=inputReader.nrOfCol())
+                  continue;
+                if(verbose_opt[0])
+                  cout << setprecision(12) << "reading image value at x,y " << x << "," << y << " (" << i << "," << j << "), ";
+                inputReader.readData(inputValue,i,j,band_opt[0]);
+                inputValues.push_back(inputValue);
+                if(inputValues.back()!=*(inputValues.begin()))
+                  isHomogeneous=false;
+                if(verbose_opt[0])
+                  cout << "input value: " << inputValue << endl;
+                pixelFlagged=false;
+                for(int iflag=0;iflag<nodata_opt.size();++iflag){
+                  if(inputValue==nodata_opt[iflag]){
+                    pixelFlagged=true;
+                    break;
+                  }
+                }
+                maskFlagged=false;//(msknodata_opt[ivalue]>=0)?false:true;
+                if(mask_opt.size()){
+                  maskReader.readData(maskValue,i,j,0);
+                  for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
+                    if(msknodata_opt[ivalue]>=0){//values set in msknodata_opt are invalid
+                      if(maskValue==msknodata_opt[ivalue]){
+                        maskFlagged=true;
+                        break;
+                      }
+                    }
+                    else{//only values set in msknodata_opt are valid
+                      if(maskValue!=-msknodata_opt[ivalue])
+                        maskFlagged=true;
+                      else{
+                        maskFlagged=false;
+                        break;
+                      }
+                    }
+                  }
+                }
+                pixelFlagged=pixelFlagged||maskFlagged;
+                if(pixelFlagged)
+                  windowHasFlag=true;
+                else
+                  windowAllFlagged=false;//at least one good pixel in neighborhood
+              }
+            }
+            //at this point we know the values for the entire window
+
+            if(homogeneous_opt[0]){//only centre pixel
+              int j=j_centre;
+              int i=i_centre;
+              //flag if not all pixels are homogeneous or if at least one pixel flagged
+
+              if(!windowHasFlag&&isHomogeneous){
+                if(output_opt.size())
+                  writeFeature->SetField(labelclass_opt[0].c_str(),static_cast<int>(inputValue));
+                if(confusion_opt[0]){
+                  ++ntotalValidation;
+                  if(classValueMap.size()){
+                    assert(inputValue<nameVector.size());
+                    string className=nameVector[static_cast<unsigned short>(inputValue)];
+                    cm.incrementResult(type2string<short>(classValueMap[referenceClassName]),type2string<short>(classValueMap[className]),1);
+                  }
+                  else{
+                    int rc=distance(referenceRange.begin(),find(referenceRange.begin(),referenceRange.end(),static_cast<unsigned short>(referenceValue)));
+                    int ic=distance(inputRange.begin(),find(inputRange.begin(),inputRange.end(),static_cast<unsigned short>(inputValue)));
+                    assert(rc<nclass);
+                    assert(ic<nclass);
+                    ++nvalidation[rc];
+                    ++resultClass[rc][ic];
+                    if(verbose_opt[0]>1)
+                      cout << "increment: " << rc << " " << referenceRange[rc] << " " << ic << " " << inputRange[ic] << endl;
+                    cm.incrementResult(cm.getClass(rc),cm.getClass(ic),1);
+                  }
+                }
+                if(inputValue==referenceValue){//correct
+                  outputValue=valueE_opt[0];
+                  if(nodata_opt.size()){
+                    if(valueE_opt[0]==nodata_opt[0])
+                      outputValue=inputValue;
+                  }
+                }
+                else if(inputValue>referenceValue)//1=forest,2=non-forest
+                  outputValue=valueO_opt[0];//omission error
+                else
+                  outputValue=valueC_opt[0];//commission error
+              }
+            }
+            else{
+              for(int windowJ=-theDim/2;windowJ<(theDim+1)/2;++windowJ){
+                for(int windowI=-theDim/2;windowI<(theDim+1)/2;++windowI){
+                  if(disc_opt[0]&&(windowI*windowI+windowJ*windowJ>(theDim/2)*(theDim/2)))
+                    continue;
+                  int j=j_centre+windowJ;
+                  //check if j is out of bounds
+                  if(static_cast<int>(j)<0||static_cast<int>(j)>=inputReader.nrOfRow())
+                    continue;
+                  int i=i_centre+windowI;
+                  //check if i is out of bounds
+                  if(static_cast<int>(i)<0||static_cast<int>(i)>=inputReader.nrOfCol())
+                    continue;
+                  if(!windowAllFlagged){
+                    ostringstream fs;
+                    if(theDim>1)
+                      fs << labelclass_opt[0] << "_" << windowJ << "_" << windowI;
+                    else
+                      fs << labelclass_opt[0];
+                    if(output_opt.size())
+                      writeFeature->SetField(fs.str().c_str(),inputValue);
+                    if(!windowJ&&!windowI){//centre pixel
+                      if(confusion_opt[0]){
+                        ++ntotalValidation;
+                        if(classValueMap.size()){
+                          assert(inputValue<nameVector.size());
+                          string className=nameVector[static_cast<unsigned short>(inputValue)];
+                          cm.incrementResult(type2string<short>(classValueMap[referenceClassName]),type2string<short>(classValueMap[className]),1);
+                        }
+                        else{
+                          int rc=distance(referenceRange.begin(),find(referenceRange.begin(),referenceRange.end(),static_cast<unsigned short>(referenceValue)));
+                          int ic=distance(inputRange.begin(),find(inputRange.begin(),inputRange.end(),static_cast<unsigned short>(inputValue)));
+                          if(rc>=nclass)
+                            continue;
+                          if(ic>=nclass)
+                            continue;
+                          // assert(rc<nclass);
+                          // assert(ic<nclass);
+                          ++nvalidation[rc];
+                          ++resultClass[rc][ic];
+                          if(verbose_opt[0]>1)
+                            cout << "increment: " << rc << " " << referenceRange[rc] << " " << ic << " " << inputRange[ic] << endl;
+                          cm.incrementResult(cm.getClass(rc),cm.getClass(ic),1);
+                        }
+                      }
+                      if(inputValue==referenceValue){//correct
+                        outputValue=valueE_opt[0];
+                        if(nodata_opt.size()){
+                          if(valueE_opt[0]==nodata_opt[0])
+                            outputValue=inputValue;
+                        }
+                      }
+                      else if(inputValue>referenceValue)//1=forest,2=non-forest
+                        outputValue=valueO_opt[0];//omission error
+                      else
+                        outputValue=valueC_opt[0];//commission error
+                    }
+                  }
+                }
+              }
+            }
+            if(output_opt.size()){
+              if(!windowAllFlagged){
+                if(verbose_opt[0])
+                  cout << "creating feature" << endl;
+                if(writeLayer->CreateFeature( writeFeature ) != OGRERR_NONE ){
+                  string errorString="Failed to create feature in OGR vector file";
+                  throw(errorString);
+                }
+              }
+              OGRFeature::DestroyFeature( writeFeature );
+            }
+            ++ifeature;
+            progress=static_cast<float>(ifeature+1)/nfeatureInLayer;
+            pfnProgress(progress,pszMessage,pProgressArg);
+          }//next feature
+        }//next layer
         if(output_opt.size())
           ogrWriter.close();
         referenceReaderOgr.close();
@@ -680,9 +687,9 @@ int main(int argc, char *argv[])
           option_opt.push_back(theInterleave);
         }
         gdalWriter.open(output_opt[0],inputReader.nrOfCol(),inputReader.nrOfRow(),1,inputReader.getDataType(),oformat_opt[0],option_opt);
-	if(nodata_opt.size())
-	  gdalWriter.GDALSetNoDataValue(nodata_opt[0]);
-	gdalWriter.copyGeoTransform(inputReader);
+        if(nodata_opt.size())
+          gdalWriter.GDALSetNoDataValue(nodata_opt[0]);
+        gdalWriter.copyGeoTransform(inputReader);
         if(colorTable_opt.size())
           gdalWriter.setColorTable(colorTable_opt[0]);
         else if(inputReader.getColorTable()!=NULL){
@@ -693,7 +700,7 @@ int main(int argc, char *argv[])
       }
       else if(verbose_opt[0])
         cout << "no output image defined" << endl;
-        
+
     }
     catch(string error){
       cout << error << endl;
@@ -742,7 +749,7 @@ int main(int argc, char *argv[])
       if(referenceRange.size()!=inputRange.size()){
         if(confusion_opt[0]||output_opt.size()){
           cout << "reference range is not equal to input range!" << endl;
-          cout << "Kappa: " << 0 << endl;    
+          cout << "Kappa: " << 0 << endl;
           cout << "total weighted: " << 0 << endl;
         }
         else
@@ -764,25 +771,25 @@ int main(int argc, char *argv[])
         inputReader.image2geo(icol,irow,x,y);
         referenceReaderGdal.geo2image(x,y,ireference,jreference);
         if(ireference<0||ireference>=referenceReaderGdal.nrOfCol()){
-	  if(rmse_opt[0]||regression_opt[0])
-	    continue;
-	  else{
-	    cerr << ireference << " out of reference range!" << endl;
-	    cerr << x << " " << y << " " << icol << " " << irow << endl;
-	    cerr << x << " " << y << " " << ireference << " " << jreference << endl;
-	    exit(1);
-	  }
+          if(rmse_opt[0]||regression_opt[0])
+            continue;
+          else{
+            cerr << ireference << " out of reference range!" << endl;
+            cerr << x << " " << y << " " << icol << " " << irow << endl;
+            cerr << x << " " << y << " " << ireference << " " << jreference << endl;
+            exit(1);
+          }
         }
         if(jreference!=oldreferencerow){
           if(jreference<0||jreference>=referenceReaderGdal.nrOfRow()){
-	    if(rmse_opt[0]||regression_opt[0])
-	      continue;
-	    else{
-	      cerr << jreference << " out of reference range!" << endl;
-	      cerr << x << " " << y << " " << icol << " " << irow << endl;
-	      cerr << x << " " << y << " " << ireference << " " << jreference << endl;
-	      exit(1);
-	    }
+            if(rmse_opt[0]||regression_opt[0])
+              continue;
+            else{
+              cerr << jreference << " out of reference range!" << endl;
+              cerr << x << " " << y << " " << icol << " " << irow << endl;
+              cerr << x << " " << y << " " << ireference << " " << jreference << endl;
+              exit(1);
+            }
           }
           else{
             referenceReaderGdal.readData(lineReference,static_cast<int>(jreference),band_opt[1]);
@@ -799,26 +806,26 @@ int main(int argc, char *argv[])
           }
         }
         if(mask_opt.size()){
-	  maskReader.geo2image(x,y,imask,jmask);
-	  if(jmask>=0&&jmask<maskReader.nrOfRow()){
-	    if(jmask!=oldmaskrow)
-	      maskReader.readData(lineMask,jmask);
-	    for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-	      if(lineMask[icol]==msknodata_opt[ivalue]){
-		flagged=true;
-		break;
-	      }
-	    }
+          maskReader.geo2image(x,y,imask,jmask);
+          if(jmask>=0&&jmask<maskReader.nrOfRow()){
+            if(jmask!=oldmaskrow)
+              maskReader.readData(lineMask,jmask);
+            for(int ivalue=0;ivalue<msknodata_opt.size();++ivalue){
+              if(lineMask[icol]==msknodata_opt[ivalue]){
+                flagged=true;
+                break;
+              }
+            }
           }
         }
         if(!flagged){
-	  if(rmse_opt[0]){//divide by image size to prevent overflow. At the end we need to take care about flagged pixels by normalizing...
-	    rmse+=static_cast<double>(lineInput[icol]-lineReference[ireference])*(lineInput[icol]-lineReference[ireference])/inputReader.nrOfCol()/inputReader.nrOfRow();
-	  }
-	  else if(regression_opt[0]){
-	    bufferInput.push_back(lineInput[icol]);
-	    bufferReference.push_back(lineReference[ireference]);
-	  }
+          if(rmse_opt[0]){//divide by image size to prevent overflow. At the end we need to take care about flagged pixels by normalizing...
+            rmse+=static_cast<double>(lineInput[icol]-lineReference[ireference])*(lineInput[icol]-lineReference[ireference])/inputReader.nrOfCol()/inputReader.nrOfRow();
+          }
+          else if(regression_opt[0]){
+            bufferInput.push_back(lineInput[icol]);
+            bufferReference.push_back(lineReference[ireference]);
+          }
 
           if(confusion_opt[0]){
             ++ntotalValidation;
@@ -834,11 +841,11 @@ int main(int argc, char *argv[])
           }
           if(lineInput[icol]==lineReference[ireference]){//correct
             if(output_opt.size()){
-	      lineOutput[icol]=valueE_opt[0];
-	      if(nodata_opt.size()){
-		if(valueE_opt[0]==nodata_opt[0])
-		  lineOutput[icol]=lineInput[icol];
-	      }
+              lineOutput[icol]=valueE_opt[0];
+              if(nodata_opt.size()){
+                if(valueE_opt[0]==nodata_opt[0])
+                  lineOutput[icol]=lineInput[icol];
+              }
             }
           }
           else{//error
@@ -848,20 +855,20 @@ int main(int argc, char *argv[])
             }
             if(output_opt.size()){
               if(lineInput[icol]>lineReference[ireference])
-		lineOutput[icol]=valueO_opt[0];//omission error
-	      else
-		lineOutput[icol]=valueC_opt[0];//commission error
+                lineOutput[icol]=valueO_opt[0];//omission error
+              else
+                lineOutput[icol]=valueC_opt[0];//commission error
             }
           }
-	}
+        }
         else{
           ++nflagged;
           if(output_opt.size()){
-	    if(nodata_opt.size())
-	      lineOutput[icol]=nodata_opt[0];
-	    else //should never occur?
-	      lineOutput[icol]=0;
-	  }	      
+            if(nodata_opt.size())
+              lineOutput[icol]=nodata_opt[0];
+            else //should never occur?
+              lineOutput[icol]=0;
+          }
         }
       }
       if(output_opt.size()){
@@ -888,35 +895,35 @@ int main(int argc, char *argv[])
       gdalWriter.close();
     else if(!confusion_opt[0]){
       if(rmse_opt[0]){
-	double normalization=1.0*inputReader.nrOfCol()*inputReader.nrOfRow()/(inputReader.nrOfCol()*inputReader.nrOfRow()-nflagged);
-	if(verbose_opt[0]){
-	  cout << "normalization: " << normalization << endl;
-	  cout << "rmse before sqrt and normalization: " << rmse << endl;
-	}
-	cout << "--rmse " << sqrt(rmse/normalization) << endl;
+        double normalization=1.0*inputReader.nrOfCol()*inputReader.nrOfRow()/(inputReader.nrOfCol()*inputReader.nrOfRow()-nflagged);
+        if(verbose_opt[0]){
+          cout << "normalization: " << normalization << endl;
+          cout << "rmse before sqrt and normalization: " << rmse << endl;
+        }
+        cout << "--rmse " << sqrt(rmse/normalization) << endl;
       }
       else if(regression_opt[0]){
-	double err=0;
-	double c0=0;
-	double c1=1;
-	statfactory::StatFactory stat;
-	if(bufferInput.size()&&bufferReference.size()){
-	  err=stat.linear_regression_err(bufferInput,bufferReference,c0,c1);
-	}
-	if(verbose_opt[0]){
-	  cout << "bufferInput.size(): " << bufferInput.size() << endl;
-	  cout << "bufferReference.size(): " << bufferReference.size() << endl;
-	  double theMin=0;
-	  double theMax=0;
-	  stat.minmax(bufferInput,bufferInput.begin(),bufferInput.end(),theMin,theMax);
-	  cout << "min,  max input: " << theMin << ", " << theMax << endl;
-	  theMin=0;
-	  theMax=0;
-	  stat.minmax(bufferReference,bufferReference.begin(),bufferReference.end(),theMin,theMax);
-	  cout << "min,  max reference: " << theMin << ", " << theMax << endl;
-	}
-	cout << "--c0 " << c0 << "--c1 " << c1 << " --rmse: " << err << endl;
-	
+        double err=0;
+        double c0=0;
+        double c1=1;
+        statfactory::StatFactory stat;
+        if(bufferInput.size()&&bufferReference.size()){
+          err=stat.linear_regression_err(bufferInput,bufferReference,c0,c1);
+        }
+        if(verbose_opt[0]){
+          cout << "bufferInput.size(): " << bufferInput.size() << endl;
+          cout << "bufferReference.size(): " << bufferReference.size() << endl;
+          double theMin=0;
+          double theMax=0;
+          stat.minmax(bufferInput,bufferInput.begin(),bufferInput.end(),theMin,theMax);
+          cout << "min,  max input: " << theMin << ", " << theMax << endl;
+          theMin=0;
+          theMax=0;
+          stat.minmax(bufferReference,bufferReference.begin(),bufferReference.end(),theMin,theMax);
+          cout << "min,  max reference: " << theMin << ", " << theMax << endl;
+        }
+        cout << "--c0 " << c0 << "--c1 " << c1 << " --rmse: " << err << endl;
+
       }
       else if(isDifferent)
         cout << input_opt[0] << " and " << reference_opt[0] << " are different" << endl;



View it on GitLab: https://salsa.debian.org/debian-gis-team/pktools/commit/93a15c23e8bc9570d57972a7b9033281c78004d4

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/pktools/commit/93a15c23e8bc9570d57972a7b9033281c78004d4
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20180819/58337aca/attachment-0001.html>


More information about the Pkg-grass-devel mailing list