[pktools] 01/05: Imported Upstream version 2.6.1

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:53:36 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch master
in repository pktools.

commit 06f80f84be0fae063797f9f8af733e5cd3f7ac3f
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Wed Dec 3 21:16:23 2014 +0100

    Imported Upstream version 2.6.1
---
 ChangeLog                    |  24 +-
 configure                    |  36 +--
 configure.ac                 |   6 +-
 ltmain.sh                    |   4 +-
 m4/libtool.m4                |  12 +-
 src/algorithms/Filter.cc     |   8 +
 src/algorithms/Filter.h      |  11 +-
 src/algorithms/Filter2d.h    |   2 +-
 src/algorithms/StatFactory.h | 336 ++++++++++++++++++-------
 src/algorithms/myfann_cpp.h  |  18 +-
 src/apps/Makefile.am         |   4 +-
 src/apps/Makefile.in         |  49 ++--
 src/apps/pkann.cc            | 116 +++++----
 src/apps/pkascii2ogr.cc      |   2 -
 src/apps/pkdumpimg.cc        |  23 +-
 src/apps/pkegcs.cc           |   2 +-
 src/apps/pkextract.cc        | 580 +++++++++++++++++++++++--------------------
 src/apps/pkfilter.cc         |   3 +-
 src/apps/pkfilterascii.cc    |   2 +-
 src/apps/pkfilterdem.cc      |   6 +-
 src/apps/pkfsann.cc          |   4 +-
 src/apps/pkfssvm.cc          |   4 +-
 src/apps/pkinfo.cc           |   2 +-
 src/apps/pkkalman.cc         |  15 +-
 src/apps/pklas2img.cc        |   2 +-
 src/apps/pkoptsvm.cc         |   4 +-
 src/apps/pkpolygonize.cc     |   2 +-
 src/apps/pkregann.cc         |   8 +-
 src/apps/pkstatascii.cc      |   2 +-
 src/apps/pksvm.cc            | 128 ++++++----
 src/base/Makefile.am         |   8 +-
 src/base/Makefile.in         | 177 +++++--------
 32 files changed, 902 insertions(+), 698 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0e626a5..bdc27ac 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -319,19 +319,23 @@ version 2.5.4
 	support statistic rules (mean, stdev, median, etc.) for point features by taking into account buffer (default= 3 by 3 pixels). If option -polygon is set, output ogr features are polygons defining the buffer.
 	changed names for maximum and minumum rule to max and min respectively
 	new options -rand and -grid to support simple random sampling and systematic grid (do not provide sample vector dataset)
- - pksvm
-	replaced options s|start and e|end with bs|bstart and be|bend
- - pkann
-	replaced options s|start and e|end with bs|bstart and be|bend
- - pkfssvm
-	replaced options s|start and e|end with bs|bstart and be|bend
- - pkfsann
-	replaced options s|start and e|end with bs|bstart and be|bend
- - pkoptsvm
-	replaced options s|start and e|end with bs|bstart and be|bend
  - ImgWriteOgr
 	overwrite existing ogr datasets per default
 
+version 2.6.1
+ - API
+	Filter.h support nodata values
+ - pkfilter
+	Declare nodata option as double (see ticket #43500)
+	Support nodata values for filtering in spectral/temporal domain (see ticket #43713)
+ - pkextract
+	extracting with absolute threshold (negative value) was selecting 1 extra sample unit
+	debug: removed (redundant?) SetGeometry after SetFrom when readFeature was of appropriate geometry type. This caused wrong polygons in output vectro dataset
+ - pksvm
+	support for mask in geo coordinates (does not need to be in same dimensions as input raster dataset, only in same projection)
+ - pkann
+	support for mask in geo coordinates (does not need to be in same dimensions as input raster dataset, only in same projection)
+
 Todo:
  - todo for API
 	ImgReaderGdal (ImgWriterGdal) open in update mode (check gdal_edit.py: http://searchcode.com/codesearch/view/18938404)
diff --git a/configure b/configure
index 133beec..86da08a 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for pktools 2.5.4.
+# Generated by GNU Autoconf 2.69 for pktools 2.6.1.
 #
 # Report bugs to <kempenep at gmail.com>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='pktools'
 PACKAGE_TARNAME='pktools'
-PACKAGE_VERSION='2.5.4'
-PACKAGE_STRING='pktools 2.5.4'
+PACKAGE_VERSION='2.6.1'
+PACKAGE_STRING='pktools 2.6.1'
 PACKAGE_BUGREPORT='kempenep at gmail.com'
 PACKAGE_URL=''
 
@@ -1366,7 +1366,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures pktools 2.5.4 to adapt to many kinds of systems.
+\`configure' configures pktools 2.6.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1436,7 +1436,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pktools 2.5.4:";;
+     short | recursive ) echo "Configuration of pktools 2.6.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1562,7 +1562,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pktools configure 2.5.4
+pktools configure 2.6.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2323,7 +2323,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by pktools $as_me 2.5.4, which was
+It was created by pktools $as_me 2.6.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3187,7 +3187,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='pktools'
- VERSION='2.5.4'
+ VERSION='2.6.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -7520,7 +7520,7 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
@@ -7545,7 +7545,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  ppc64-*linux*|powerpc64-*linux*)
+	  powerpc64le-*)
+	    LD="${LD-ld} -m elf32lppclinux"
+	    ;;
+	  powerpc64-*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -7564,7 +7567,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  ppc*-*linux*|powerpc*-*linux*)
+	  powerpcle-*)
+	    LD="${LD-ld} -m elf64lppc"
+	    ;;
+	  powerpc-*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -18923,7 +18929,7 @@ $as_echo "$GDAL_OGR_ENABLED" >&6; }
     fi
 
 
-    gdal_version_req=1.9.0
+    gdal_version_req=1.10.0
     if test "$found_gdal" = "yes" -a -n "$gdal_version_req"; then
 
         { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GDAL version is >= $gdal_version_req" >&5
@@ -19588,7 +19594,7 @@ fi
 # For information on how to properly maintain the library version information,
 # refer to the libtool manual, section "Updating library version information":
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-PKTOOLS_SO_VERSION=1:2:0
+PKTOOLS_SO_VERSION=1:3:0
 
 
 # files to generate via autotools (.am or .in source files)
@@ -20166,7 +20172,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by pktools $as_me 2.5.4, which was
+This file was extended by pktools $as_me 2.6.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20232,7 +20238,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-pktools config.status 2.5.4
+pktools config.status 2.6.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index e769ba1..469ba42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([pktools], [2.5.4], [kempenep at gmail.com])
+AC_INIT([pktools], [2.6.1], [kempenep at gmail.com])
 #AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AM_INIT_AUTOMAKE([-Wall -Wno-extra-portability foreign])
 #AM_INIT_AUTOMAKE([subdir-objects]) #not working due to bug in autoconf, see Debian list: Bug #752993)
@@ -22,7 +22,7 @@ LT_INIT
 
 # check if the source folder is correct
 AC_CONFIG_SRCDIR([src/apps/pkinfo.cc])
-AX_LIB_GDAL([1.9.0]) dnl uncomment if gdal version 1.10.0 is required
+AX_LIB_GDAL([1.10.0]) dnl uncomment if gdal version 1.10.0 is required
 
 AC_CHECK_HEADERS([gdal.h])
 
@@ -97,7 +97,7 @@ AC_SUBST([LIBS])
 # For information on how to properly maintain the library version information,
 # refer to the libtool manual, section "Updating library version information":
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-AC_SUBST([PKTOOLS_SO_VERSION], [1:2:0])
+AC_SUBST([PKTOOLS_SO_VERSION], [1:3:0])
 
 # files to generate via autotools (.am or .in source files)
 AC_CONFIG_HEADERS([config.h])
diff --git a/ltmain.sh b/ltmain.sh
index b9205ee..a356aca 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -70,7 +70,7 @@
 #         compiler:		$LTCC
 #         compiler flags:		$LTCFLAGS
 #         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.2ubuntu1
+#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
 #         automake:	$automake_version
 #         autoconf:	$autoconf_version
 #
@@ -80,7 +80,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1.2ubuntu1"
+VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
 TIMESTAMP=""
 package_revision=1.3337
 
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 02b4bbe..d7c043f 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1312,7 +1312,7 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
@@ -1333,7 +1333,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 		;;
 	    esac
 	    ;;
-	  ppc64-*linux*|powerpc64-*linux*)
+	  powerpc64le-*)
+	    LD="${LD-ld} -m elf32lppclinux"
+	    ;;
+	  powerpc64-*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1352,7 +1355,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  ppc*-*linux*|powerpc*-*linux*)
+	  powerpcle-*)
+	    LD="${LD-ld} -m elf64lppc"
+	    ;;
+	  powerpc-*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
diff --git a/src/algorithms/Filter.cc b/src/algorithms/Filter.cc
index 4241d41..f2b6aa0 100644
--- a/src/algorithms/Filter.cc
+++ b/src/algorithms/Filter.cc
@@ -51,6 +51,13 @@ void filter::Filter::setTaps(const vector<double> &taps, bool normalize)
   assert(m_taps.size()%2);
 }
 
+int filter::Filter::pushNoDataValue(double noDataValue)
+{
+  if(find(m_noDataValues.begin(),m_noDataValues.end(),noDataValue)==m_noDataValues.end())
+    m_noDataValues.push_back(noDataValue);
+  return(m_noDataValues.size());
+}
+
 void filter::Filter::dwtForward(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& wavelet_type, int family){
   const char* pszMessage;
   void* pProgressArg=NULL;
@@ -338,6 +345,7 @@ void filter::Filter::stat(const ImgReaderGdal& input, ImgWriterGdal& output, con
   assert(output.nrOfCol()==input.nrOfCol());
   vector<double> lineOutput(output.nrOfCol());
   statfactory::StatFactory stat;
+  stat.setNoDataValues(m_noDataValues);
   const char* pszMessage;
   void* pProgressArg=NULL;
   GDALProgressFunc pfnProgress=GDALTermProgress;
diff --git a/src/algorithms/Filter.h b/src/algorithms/Filter.h
index 705bfc6..a75626c 100644
--- a/src/algorithms/Filter.h
+++ b/src/algorithms/Filter.h
@@ -65,6 +65,7 @@ public:
   void setTaps(const std::vector<double> &taps, bool normalize=true);
   void pushClass(short theClass=1){m_class.push_back(theClass);};
   void pushMask(short theMask=0){m_mask.push_back(theMask);};
+  int pushNoDataValue(double noDataValue=0);//{m_mask.push_back(theMask);};
   template<class T> void filter(const std::vector<T>& input, std::vector<T>& output);
   template<class T> void filter(const std::vector<T>& input, std::vector<T>& output, const std::string& method, int dim);
   template<class T> void smooth(const std::vector<T>& input, std::vector<T>& output, short dim);
@@ -140,7 +141,8 @@ private:
   std::vector<double> m_taps;
   std::vector<short> m_class;
   std::vector<short> m_mask;
-   std::string m_padding;
+  std::string m_padding;
+  std::vector<double> m_noDataValues;
 };
 
 
@@ -424,7 +426,7 @@ template<class T> void Filter::filter(const std::vector<T>& input, std::vector<T
   int i=0;
   //start: extend input by padding
   for(i=0;i<m_taps.size()/2;++i){
-    //todo:introduce nodata
+    //todo:introduce nodata?
     output[i]=m_taps[m_taps.size()/2]*input[i];
     for(int t=1;t<=m_taps.size()/2;++t){
       output[i]+=m_taps[m_taps.size()/2+t]*input[i+t];
@@ -460,9 +462,9 @@ template<class T> void Filter::filter(const std::vector<T>& input, std::vector<T
   }
   //end: extend input by padding
   for(i=input.size()-m_taps.size()/2;i<input.size();++i){
-    //todo:introduce nodata
+    //todo:introduce nodata?
     output[i]=m_taps[m_taps.size()/2]*input[i];
-    //todo:introduce nodata
+    //todo:introduce nodata?
     for(int t=1;t<=m_taps.size()/2;++t){
       output[i]+=m_taps[m_taps.size()/2-t]*input[i-t];
       if(i+t<input.size())
@@ -497,6 +499,7 @@ template<class T> void Filter::filter(const std::vector<T>& input, std::vector<T
   output.resize(input.size());
   int i=0;
   statfactory::StatFactory stat;
+  stat.setNoDataValues(m_noDataValues);
   std::vector<T> statBuffer;
   short binValue=0;
   //start: extend input by padding
diff --git a/src/algorithms/Filter2d.h b/src/algorithms/Filter2d.h
index d4e1917..221c1df 100644
--- a/src/algorithms/Filter2d.h
+++ b/src/algorithms/Filter2d.h
@@ -107,7 +107,7 @@ public:
   template<class T> void dwtCut(Vector2d<T>& data, const std::string& wavelet_type, int family, double cut);
   void majorVoting(const std::string& inputFilename, const std::string& outputFilename,int dim=0,const std::vector<int> &prior=std::vector<int>());
   /* void homogeneousSpatial(const std::string& inputFilename, const std::string& outputFilename, int dim, bool disc=false, int noValue=0); */
-  void doit(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short down=2, bool disc=false);
+  void doit(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dim, short down=1, bool disc=false);
   void doit(const ImgReaderGdal& input, ImgWriterGdal& output, const std::string& method, int dimX, int dimY, short down=1, bool disc=false);
   void mrf(const ImgReaderGdal& input, ImgWriterGdal& output, int dimX, int dimY, double beta, bool eightConnectivity=true, short down=1, bool verbose=false);
   void mrf(const ImgReaderGdal& input, ImgWriterGdal& output, int dimX, int dimY, Vector2d<double> beta, bool eightConnectivity=true, short down=1, bool verbose=false);
diff --git a/src/algorithms/StatFactory.h b/src/algorithms/StatFactory.h
index abf7640..4e575e3 100644
--- a/src/algorithms/StatFactory.h
+++ b/src/algorithms/StatFactory.h
@@ -210,149 +210,238 @@ private:
 
 template<class T> inline typename std::vector<T>::const_iterator StatFactory::mymin(const std::vector<T>& v, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end) const
 {
+  bool isValid=false;
   typename std::vector<T>::const_iterator tmpIt=begin;
-  for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
-    if(!isNoData(*it))
+  for(typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
+    if(!isNoData(*it)){
+      isValid=true;
       if(*tmpIt>*it)
 	tmpIt=it;
+    }
+  }
+  if(isValid)
+    return tmpIt;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
   }
-  return tmpIt;
 }
 
 template<class T> inline typename std::vector<T>::iterator StatFactory::mymin(const std::vector<T>& v, typename std::vector<T>::iterator begin, typename std::vector<T>::iterator end) const
 {
+  bool isValid=false;
   typename std::vector<T>::iterator tmpIt=begin;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
-    if(!isNoData(*it))
+    if(!isNoData(*it)){
+      isValid=true;
       if(*tmpIt>*it)
 	tmpIt=it;
+    }
+  }
+  if(isValid)
+    return tmpIt;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
   }
-  return tmpIt;
 }
 
 template<class T> inline  typename std::vector<T>::const_iterator StatFactory::mymin(const std::vector<T>& v, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end, T minConstraint) const
 {
+  bool isValid=false;
   typename std::vector<T>::const_iterator tmpIt=v.end();
   T minValue=minConstraint;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if((minConstraint<=*it)&&(*it<=minValue)){
       tmpIt=it;
       minValue=*it;
     }
   }
-  return tmpIt;
+  if(isValid)
+    return tmpIt;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline typename std::vector<T>::iterator StatFactory::mymin(const std::vector<T>& v, typename std::vector<T>::iterator begin, typename std::vector<T>::iterator end, T minConstraint) const
 {
+  bool isValid=false;
   typename std::vector<T>::iterator tmpIt=v.end();
   T minValue=minConstraint;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if((minConstraint<=*it)&&(*it<=minValue)){
       tmpIt=it;
       minValue=*it;
     }
   }
-  return tmpIt;
+  if(isValid)
+    return tmpIt;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline typename std::vector<T>::const_iterator StatFactory::mymax(const std::vector<T>& v, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end) const
 {
+  bool isValid=false;
   typename std::vector<T>::const_iterator tmpIt=begin;
   for (typename std::vector<T>::iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(*tmpIt<*it)
       tmpIt=it;
   }
-  return tmpIt;
+  if(isValid)
+    return tmpIt;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline typename std::vector<T>::iterator StatFactory::mymax(const std::vector<T>& v, typename std::vector<T>::iterator begin, typename std::vector<T>::iterator end) const
 {
+  bool isValid=false;
   typename std::vector<T>::iterator tmpIt=begin;
   for (typename std::vector<T>::iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(*tmpIt<*it)
       tmpIt=it;
   }
-  return tmpIt;
+  if(isValid)
+    return tmpIt;
+  else
+    return end;
 }
 
 template<class T> inline typename std::vector<T>::const_iterator StatFactory::mymax(const std::vector<T>& v, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end, T maxConstraint) const
 {
+  bool isValid=false;
   typename std::vector<T>::const_iterator tmpIt=v.end();
   T maxValue=maxConstraint;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if((maxValue<=*it)&&(*it<=maxConstraint)){
       tmpIt=it;
       maxValue=*it;
     }
   }
-  return tmpIt;
+  if(isValid)
+    return tmpIt;
+  else  
+    return end;
 }
 
 template<class T> inline typename std::vector<T>::iterator StatFactory::mymax(const std::vector<T>& v, typename std::vector<T>::iterator begin, typename std::vector<T>::iterator end, T maxConstraint) const
 {
+  bool isValid=false;
   typename std::vector<T>::iterator tmpIt=v.end();
   T maxValue=maxConstraint;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if((maxValue<=*it)&&(*it<=maxConstraint)){
       tmpIt=it;
       maxValue=*it;
     }
   }
-  return tmpIt;
+  if(isValid)
+    return tmpIt;
+  else  
+    return end;
 }
 
-
-
-
 template<class T> inline T StatFactory::mymin(const std::vector<T>& v) const
 {
+  bool isValid=false;
   T minValue=*(v.begin());
   for (typename std::vector<T>::const_iterator it = v.begin(); it!=v.end(); ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(minValue>*it)
       minValue=*it;
   }
-  return minValue;
+  if(isValid)
+    return minValue;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
  template<class T> inline T StatFactory::mymin(const std::vector<T>& v, T minConstraint) const
 {
+  bool isValid=false;
   T minValue=minConstraint;
   for (typename std::vector<T>::const_iterator it = v.begin(); it!=v.end(); ++it){
+    if(isNoData(*it))
+      continue;
+    isValid=true;
     if((minConstraint<=*it)&&(*it<=minValue))
       minValue=*it;
   }
-  return minValue;
+  if(isValid)
+    return minValue;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline T StatFactory::mymax(const std::vector<T>& v) const
 {
+  bool isValid=false;
   T maxValue=*(v.begin());
   for (typename std::vector<T>::const_iterator it = v.begin(); it!=v.end(); ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(maxValue<*it)
       maxValue=*it;
   }
-  return maxValue;
+  if(isValid)
+    return maxValue;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline T StatFactory::mymax(const std::vector<T>& v, T maxConstraint) const
 {
+  bool isValid=false;
   T maxValue=maxConstraint;
   for (typename std::vector<T>::const_iterator it = v.begin(); it!=v.end(); ++it){
     if(isNoData(*it))
@@ -360,56 +449,95 @@ template<class T> inline T StatFactory::mymax(const std::vector<T>& v, T maxCons
     if((maxValue<=*it)&&(*it<=maxConstraint))
       maxValue=*it;
   }
-  return maxValue;
+  if(isValid)
+    return maxValue;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline typename std::vector<T>::const_iterator StatFactory::absmax(const std::vector<T>& v, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end) const
 {
+  bool isValid=false;
   typename std::vector<T>::const_iterator tmpIt=begin;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(abs(*tmpIt)<abs(*it))
       tmpIt=it;
   }
-  return tmpIt;
+  if(isValid)
+    return tmpIt;
+  else
+    return end;
 }
 
 template<class T> inline typename std::vector<T>::const_iterator StatFactory::absmin(const std::vector<T>& v, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end) const
 {
+  bool isValid=false;
   typename std::vector<T>::const_iterator tmpIt=begin;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(abs(*tmpIt)>abs(*it))
       tmpIt=it;
   }
+  if(isValid)
+    return tmpIt;
+  else
+    return end;
 }
 
 template<class T> inline void StatFactory::minmax(const std::vector<T>& v, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end, T& theMin, T& theMax) const
 {
+  bool isValid=false;
   theMin=*begin;
   theMax=*begin;
   for (typename std::vector<T>::const_iterator it = begin; it!=end; ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(theMin>*it)
       theMin=*it;
     if(theMax<*it)
       theMax=*it;
   }
+  if(!isValid){
+    if(m_noDataValues.size()){
+      theMin=m_noDataValues[0];
+      theMax=m_noDataValues[0];
+    }
+    else{
+      std::string errorString="Error: no valid data found";
+      throw(errorString);
+    }
+  }
 }
 
 template<class T> inline T StatFactory::sum(const std::vector<T>& v) const
 {
+  bool isValid=false;
   typename std::vector<T>::const_iterator it;
   T tmpSum=0;
   for (it = v.begin(); it!= v.end(); ++it){
     if(isNoData(*it))
       continue;
+    isValid=true;
     tmpSum+=*it;
   }
-  return tmpSum;
+  if(isValid)
+    return tmpSum;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline double StatFactory::mean(const std::vector<T>& v) const
@@ -426,18 +554,24 @@ template<class T> inline double StatFactory::mean(const std::vector<T>& v) const
   }
   if(validSize)
     return static_cast<double>(tmpSum)/validSize;
-  else
-    return 0;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> inline void StatFactory::eraseNoData(std::vector<T>& v) const
 {
-  typename std::vector<T>::iterator it=v.begin();
-  while(it!=v.end()){
-    if(isNoData(*it))
-      v.erase(it);
-    else
-      ++it;
+  if(m_noDataValues.size()){
+    typename std::vector<T>::iterator it=v.begin();
+    while(it!=v.end()){
+      if(isNoData(*it))
+	v.erase(it);
+      else
+	++it;
+    }
   }
 }
 
@@ -445,11 +579,19 @@ template<class T> T StatFactory::median(const std::vector<T>& v) const
 {
   std::vector<T> tmpV=v;
   eraseNoData(tmpV);
-  sort(tmpV.begin(),tmpV.end());
-  if(tmpV.size()%2)
-    return tmpV[tmpV.size()/2];
-  else
-    return 0.5*(tmpV[tmpV.size()/2-1]+tmpV[tmpV.size()/2]);
+  if(tmpV.size()){
+    sort(tmpV.begin(),tmpV.end());
+    if(tmpV.size()%2)
+      return tmpV[tmpV.size()/2];
+    else
+      return 0.5*(tmpV[tmpV.size()/2-1]+tmpV[tmpV.size()/2]);
+  }
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> double StatFactory::var(const std::vector<T>& v) const
@@ -470,17 +612,12 @@ template<class T> double StatFactory::var(const std::vector<T>& v) const
     m1/=validSize;
     return m2-m1*m1;
   }
-  else
-    return 0;
-  /* double v1=0; */
-  /* double m1=mean(v); */
-  /* double n=v.size(); */
-  /* assert(n>1); */
-  /* for (it = v.begin(); it!= v.end(); ++it) */
-  /*   v1+=(*it-m1)*(*it-m1); */
-  /* v1/=(n-1); */
-  /* assert(v1>=0); */
-  /* return v1; */
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> double StatFactory::moment(const std::vector<T>& v, int n) const
@@ -498,9 +635,12 @@ template<class T> double StatFactory::moment(const std::vector<T>& v, int n) con
   }
   if(validSize)
     return m/validSize;
-  else
-    return 0;
-  /* return m/v.size(); */
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
   //central moment
@@ -517,17 +657,25 @@ template<class T> double StatFactory::cmoment(const std::vector<T>& v, int n) co
     m+=pow((*it-m1),n);
     ++validSize;
   }
-  return m/validSize;
-  return m/v.size();
+  if(validSize)
+    return m/validSize;
+  else if(m_noDataValues.size())
+    return m_noDataValues[0];
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T> double StatFactory::skewness(const std::vector<T>& v) const
 {
+  //todo: what if nodata value?
   return cmoment(v,3)/pow(var(v),1.5);
 }
 
 template<class T> double StatFactory::kurtosis(const std::vector<T>& v) const
 {
+  //todo: what if nodata value?
   double m2=cmoment(v,2);
   double m4=cmoment(v,4);
   return m4/m2/m2-3.0;
@@ -552,15 +700,14 @@ template<class T> void StatFactory::meanVar(const std::vector<T>& v, double& m1,
     m1/=validSize;
     v1=m2-m1*m1;
   }
-  /* typename std::vector<T>::const_iterator it; */
-  /* v1=0; */
-  /* m1=mean(v); */
-  /* double n=v.size(); */
-  /* assert(n>1); */
-  /* for (it = v.begin(); it!= v.end(); ++it) */
-  /*   v1+=(*(it)-m1)*(*(it)-m1); */
-  /* v1/=(n-1); */
-  /* assert(v1>=0); */
+  else if(m_noDataValues.size()){
+    m1=m_noDataValues[0];
+    v1=m_noDataValues[0];
+  }
+  else{
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
 }
 
 template<class T1, class T2> void StatFactory::scale2byte(const std::vector<T1>& input, std::vector<T2>& output, unsigned char lbound,  unsigned char ubound) const
@@ -570,8 +717,10 @@ template<class T1, class T2> void StatFactory::scale2byte(const std::vector<T1>&
   T1 maximum=mymax(input);
   assert(maximum>minimum);
   double scale=(ubound-lbound)/(maximum-minimum);
-  for (int i=0;i<input.size();++i)
+  //todo: what if nodata value?
+  for (int i=0;i<input.size();++i){
     output[i]=scale*(input[i]-(minimum))+lbound;
+  }
 }
 
 template<class T> void  StatFactory::distribution(const std::vector<T>& input, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end, std::vector<double>& output, int nbin, T &minimum, T &maximum, double sigma, const std::string &filename) const
@@ -594,11 +743,15 @@ template<class T> void  StatFactory::distribution(const std::vector<T>& input, t
     throw(s.str());
   }
   assert(nbin);
-  assert(input.size());
+  if(!input.size()){
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
   if(output.size()!=nbin){
     output.resize(nbin);
     for(int i=0;i<nbin;output[i++]=0);
   }
+  bool isValid=false;
   typename std::vector<T>::const_iterator it;
   for(it=begin;it!=end;++it){
     if(*it<minimum)
@@ -607,6 +760,7 @@ template<class T> void  StatFactory::distribution(const std::vector<T>& input, t
       continue;
     if(isNoData(*it))
       continue;
+    isValid=true;
     if(sigma>0){
       // minimum-=2*sigma;
       // maximum+=2*sigma;
@@ -632,7 +786,11 @@ template<class T> void  StatFactory::distribution(const std::vector<T>& input, t
       //   ++output[static_cast<int>(static_cast<double>((*it)-minimum)/(maximum-minimum)*nbin)];
     }
   }
-  if(!filename.empty()){
+  if(!isValid){
+    std::string errorString="Error: no valid data found";
+    throw(errorString);
+  }
+  else if(!filename.empty()){
     std::ofstream outputfile;
     outputfile.open(filename.c_str());
     if(!outputfile){
@@ -726,14 +884,11 @@ template<class T> void  StatFactory::distribution2d(const std::vector<T>& inputX
   }
 }
 
+//todo: what with nodata values?
 template<class T> void  StatFactory::percentiles (const std::vector<T>& input, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end, std::vector<T>& output, int nbin, T &minimum, T &maximum, const std::string &filename) const
 {
   if(maximum<=minimum)
     minmax(input,begin,end,minimum,maximum);
-  // if(!minimum)
-  //   minimum=*(min(input,begin,end));
-  // if(!maximum)
-  //   maximum=*(max(input,begin,end));
   assert(maximum>minimum);
   assert(nbin>1);
   assert(input.size());
@@ -757,7 +912,6 @@ template<class T> void  StatFactory::percentiles (const std::vector<T>& input, t
       ++vit;
     }
     if(inputBin.size()){
-      /* output[ibin]=median(inputBin); */
       output[ibin]=mymax(inputBin);
     }
   }
@@ -775,27 +929,6 @@ template<class T> void  StatFactory::percentiles (const std::vector<T>& input, t
   }
 }
 
-// template<class T> void  StatFactory::cumulative (const std::vector<T>& input, typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end, std::vector<int>& output, int nbin, T &minimum, T &maximum)
-// {
-//   assert(nbin>1);
-//   assert(input.size());
-//   distribution(input,output,nbin,minimum,maximum);
-//   for(std::vector<int>::iterator it=begin+1;it!=end;++it)
-//     *it+=*(it-1);
-//   if(!filename.empty()){
-//     std::ofstream outputfile;
-//     outputfile.open(filename.c_str());
-//     if(!outputfile){
-//       std::ostringstream s;
-//       s<<"error opening cumulative file , " << filename;
-//       throw(s.str());
-//     }
-//     for(int bin=0;bin<nbin;++bin)
-//       outputfile << (maximum-minimum)*bin/(nbin-1)+minimum << " " << static_cast<double>(output[bin])/input.size() << std::endl;
-//     outputfile.close();
-//   }
-// }
-
 template<class T> void StatFactory::signature(const std::vector<T>& input, double&k, double& alpha, double& beta, double e) const
 {
   double m1=moment(input,1);
@@ -803,6 +936,7 @@ template<class T> void StatFactory::signature(const std::vector<T>& input, doubl
   signature(m1,m2,k,alpha,beta,e);
 }
 
+//todo: what with nodata values?
 template<class T> void StatFactory::normalize(const std::vector<T>& input, std::vector<double>& output) const{
   double total=sum(input);
   if(total){
@@ -814,6 +948,7 @@ template<class T> void StatFactory::normalize(const std::vector<T>& input, std::
     output=input;
 }
 
+//todo: what with nodata values?
 template<class T> void StatFactory::normalize_pct(std::vector<T>& input) const{
   double total=sum(input);
   if(total){
@@ -828,6 +963,8 @@ template<class T> double StatFactory::rmse(const std::vector<T>& x, const std::v
   assert(x.size());
   double mse=0;
   for(int isample=0;isample<x.size();++isample){
+    if(isNoData(x[isample])||isNoData(y[isample]))
+       continue;
     double e=x[isample]-y[isample];
     mse+=e*e/x.size();
   }
@@ -843,6 +980,7 @@ template<class T> double StatFactory::correlation(const std::vector<T>& x, const
   meanVar(x,meanX,varX);
   meanVar(y,meanY,varY);
   double denom = sqrt(varX*varY);
+  bool isValid=false;
   if(denom){
     //Calculate the correlation series
     sXY = 0;
@@ -850,19 +988,31 @@ template<class T> double StatFactory::correlation(const std::vector<T>& x, const
       int j = i + delay;
       if (j < 0 || j >= y.size())
         continue;
+      else if(isNoData(x[i])||isNoData(y[j]))
+	continue;
       else{
+	isValid=true;
         assert(i>=0&&i<x.size());
         assert(j>=0&&j<y.size());
         sXY += (x[i] - meanX) * (y[j] - meanY);
       }
     }
-    double minSize=(x.size()<y.size())?x.size():y.size();
-    return(sXY / denom / (minSize-1));
+    if(isValid){
+      double minSize=(x.size()<y.size())?x.size():y.size();
+      return(sXY / denom / (minSize-1));
+    }
+    else if(m_noDataValues.size())
+      return m_noDataValues[0];
+    else{
+      std::string errorString="Error: no valid data found";
+      throw(errorString);
+    }
   }
   else
     return 0;
 }
 
+//todo: what if no valid data?
 template<class T> double StatFactory::cross_correlation(const std::vector<T>& x, const std::vector<T>& y, int maxdelay, std::vector<T>& z) const{
   z.clear();
   double sumCorrelation=0;
@@ -873,6 +1023,7 @@ template<class T> double StatFactory::cross_correlation(const std::vector<T>& x,
   return sumCorrelation;
 }
 
+//todo: nodata?
 template<class T> double StatFactory::linear_regression(const std::vector<T>& x, const std::vector<T>& y, double &c0, double &c1) const{
   assert(x.size()==y.size());
   assert(x.size());
@@ -884,6 +1035,7 @@ template<class T> double StatFactory::linear_regression(const std::vector<T>& x,
   return (1-sumsq/var(y)/(y.size()-1));
 }
 
+//todo: nodata?
 template<class T> double StatFactory::linear_regression_err(const std::vector<T>& x, const std::vector<T>& y, double &c0, double &c1) const{
   assert(x.size()==y.size());
   assert(x.size());
@@ -898,6 +1050,7 @@ template<class T> double StatFactory::linear_regression_err(const std::vector<T>
 //alternatively: use GNU scientific library:
 // gsl_stats_correlation (const double data1[], const size_t stride1, const double data2[], const size_t stride2, const size_t n)
 
+//todo: nodata?
 template<class T> void StatFactory::interpolateUp(const std::vector<double>& wavelengthIn, const std::vector<T>& input, const std::vector<double>& wavelengthOut, const std::string& type, std::vector<T>& output, bool verbose) const{
   assert(wavelengthIn.size());
   assert(input.size()==wavelengthIn.size());
@@ -969,6 +1122,7 @@ template<class T> void StatFactory::interpolateUp(const std::vector<double>& wav
 //   gsl_interp_accel_free(acc);
 // }
 
+//todo: nodata?
 template<class T> void StatFactory::interpolateUp(const std::vector<T>& input, std::vector<T>& output, int nbin) const
 {
   assert(input.size());
@@ -990,6 +1144,7 @@ template<class T> void StatFactory::interpolateUp(const std::vector<T>& input, s
   }
 }
 
+//todo: nodata?
 template<class T> void StatFactory::nearUp(const std::vector<T>& input, std::vector<T>& output) const
 {
   assert(input.size());
@@ -1006,6 +1161,7 @@ template<class T> void StatFactory::nearUp(const std::vector<T>& input, std::vec
   }
 }
 
+//todo: nodata?
 template<class T> void StatFactory::interpolateUp(double* input, int dim, std::vector<T>& output, int nbin)
 {
   assert(nbin);
@@ -1025,6 +1181,7 @@ template<class T> void StatFactory::interpolateUp(double* input, int dim, std::v
   }
 }
 
+//todo: nodata?
 template<class T> void StatFactory::interpolateDown(const std::vector<T>& input, std::vector<T>& output, int nbin) const
 {
   assert(input.size());
@@ -1043,6 +1200,7 @@ template<class T> void StatFactory::interpolateDown(const std::vector<T>& input,
   }
 }
 
+//todo: nodata?
 template<class T> void StatFactory::interpolateDown(double* input, int dim, std::vector<T>& output, int nbin)
 {
   assert(nbin);
diff --git a/src/algorithms/myfann_cpp.h b/src/algorithms/myfann_cpp.h
index 29e8997..6e1c370 100644
--- a/src/algorithms/myfann_cpp.h
+++ b/src/algorithms/myfann_cpp.h
@@ -1061,14 +1061,16 @@ public:
         bool create_standard(unsigned int num_layers, ...)
         {
             va_list layers;
-            unsigned int arr[num_layers];
+			std::vector<unsigned int> arr(num_layers);//pk
+            //unsigned int arr[num_layers];
 
             va_start(layers, num_layers);
             /* bool status = create_standard_array(num_layers, */
             /*     reinterpret_cast<const unsigned int *>(layers)); */
             for (unsigned int ii = 0; ii < num_layers; ii++)
                 arr[ii] = va_arg(layers, unsigned int);
-            bool status = create_standard_array(num_layers, arr);
+            bool status = create_standard_array(num_layers, &(arr[0]));//pk
+            //bool status = create_standard_array(num_layers, arr);
             va_end(layers);
             return status;
         }
@@ -1116,7 +1118,8 @@ public:
         bool create_sparse(float connection_rate, unsigned int num_layers, ...)
         {
             va_list layers;
-            unsigned int arr[num_layers];
+			std::vector<unsigned int> arr(num_layers);//pk
+            //unsigned int arr[num_layers];
 
             va_start(layers, num_layers);
             /* bool status = create_sparse_array(connection_rate, num_layers, */
@@ -1124,7 +1127,8 @@ public:
 
             for (unsigned int ii = 0; ii < num_layers; ii++)
                 arr[ii] = va_arg(layers, unsigned int);
-            bool status = create_sparse_array(connection_rate, num_layers, arr);
+            bool status = create_sparse_array(connection_rate, num_layers, &(arr[0]));//pk
+            //bool status = create_sparse_array(connection_rate, num_layers, arr);
   
             va_end(layers);
             return status;
@@ -1170,14 +1174,16 @@ public:
         bool create_shortcut(unsigned int num_layers, ...)
         {
             va_list layers;
-            unsigned int arr[num_layers];
+			std::vector<unsigned int> arr(num_layers);//pk
+            //unsigned int arr[num_layers];
 
             va_start(layers, num_layers);
             /* bool status = create_shortcut_array(num_layers, */
             /*     reinterpret_cast<const unsigned int *>(layers)); */
             for (unsigned int ii = 0; ii < num_layers; ii++)
                 arr[ii] = va_arg(layers, unsigned int);
-            bool status = create_shortcut_array(num_layers, arr);
+            bool status = create_shortcut_array(num_layers, &(arr[0]));//
+            //bool status = create_shortcut_array(num_layers, arr);
 
             va_end(layers);
             return status;
diff --git a/src/apps/Makefile.am b/src/apps/Makefile.am
index 0e130df..a2a243a 100644
--- a/src/apps/Makefile.am
+++ b/src/apps/Makefile.am
@@ -1,6 +1,6 @@
 AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(GDAL_CFLAGS) @AM_CXXFLAGS@
-AM_LDFLAGS = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la $(top_builddir)/src/base/libbase.la @AM_LDFLAGS@
-LDADD = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la $(top_builddir)/src/base/libbase.la
+AM_LDFLAGS = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la @AM_LDFLAGS@
+LDADD = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la
 ###############################################################################
 # THE PROGRAMS TO BUILD
 ###############################################################################
diff --git a/src/apps/Makefile.in b/src/apps/Makefile.in
index fe20b40..363a78f 100644
--- a/src/apps/Makefile.in
+++ b/src/apps/Makefile.in
@@ -123,8 +123,7 @@ am__DEPENDENCIES_1 =
 am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 @USE_FANN_TRUE at pkann_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 @USE_FANN_TRUE@	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
 AM_V_lt = $(am__v_lt_ at AM_V@)
@@ -140,32 +139,28 @@ pkascii2img_LDADD = $(LDADD)
 pkascii2img_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkascii2ogr_OBJECTS = pkascii2ogr.$(OBJEXT)
 pkascii2ogr_OBJECTS = $(am_pkascii2ogr_OBJECTS)
 pkascii2ogr_LDADD = $(LDADD)
 pkascii2ogr_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkcomposite_OBJECTS = pkcomposite.$(OBJEXT)
 pkcomposite_OBJECTS = $(am_pkcomposite_OBJECTS)
 pkcomposite_LDADD = $(LDADD)
 pkcomposite_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkcreatect_OBJECTS = pkcreatect.$(OBJEXT)
 pkcreatect_OBJECTS = $(am_pkcreatect_OBJECTS)
 pkcreatect_LDADD = $(LDADD)
 pkcreatect_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkcrop_OBJECTS = pkcrop.$(OBJEXT)
 pkcrop_OBJECTS = $(am_pkcrop_OBJECTS)
 pkcrop_DEPENDENCIES =
@@ -181,16 +176,14 @@ pkdumpimg_LDADD = $(LDADD)
 pkdumpimg_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkdumpogr_OBJECTS = pkdumpogr.$(OBJEXT)
 pkdumpogr_OBJECTS = $(am_pkdumpogr_OBJECTS)
 pkdumpogr_LDADD = $(LDADD)
 pkdumpogr_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkeditogr_OBJECTS = pkeditogr.$(OBJEXT)
 pkeditogr_OBJECTS = $(am_pkeditogr_OBJECTS)
 pkeditogr_DEPENDENCIES = $(am__DEPENDENCIES_2)
@@ -206,8 +199,7 @@ pkextract_LDADD = $(LDADD)
 pkextract_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkfillnodata_OBJECTS = pkfillnodata.$(OBJEXT)
 pkfillnodata_OBJECTS = $(am_pkfillnodata_OBJECTS)
 pkfillnodata_LDADD = $(LDADD)
@@ -215,8 +207,7 @@ pkfillnodata_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkfilter_OBJECTS = pkfilter.$(OBJEXT)
 pkfilter_OBJECTS = $(am_pkfilter_OBJECTS)
 pkfilter_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
@@ -247,8 +238,7 @@ pkgetmask_LDADD = $(LDADD)
 pkgetmask_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkinfo_OBJECTS = pkinfo.$(OBJEXT)
 pkinfo_OBJECTS = $(am_pkinfo_OBJECTS)
 pkinfo_DEPENDENCIES =
@@ -267,8 +257,7 @@ pkndvi_LDADD = $(LDADD)
 pkndvi_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am__pkoptsvm_SOURCES_DIST = $(top_srcdir)/src/algorithms/OptFactory.h \
 	$(top_srcdir)/src/algorithms/CostFactorySVM.h pkoptsvm.cc
 @USE_NLOPT_TRUE at am_pkoptsvm_OBJECTS = pkoptsvm.$(OBJEXT)
@@ -282,16 +271,14 @@ pkpolygonize_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkreclass_OBJECTS = pkreclass.$(OBJEXT)
 pkreclass_OBJECTS = $(am_pkreclass_OBJECTS)
 pkreclass_LDADD = $(LDADD)
 pkreclass_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am__pkregann_SOURCES_DIST = $(top_srcdir)/src/algorithms/myfann_cpp.h \
 	pkregann.cc
 @USE_FANN_TRUE at am_pkregann_OBJECTS = pkregann-pkregann.$(OBJEXT)
@@ -308,16 +295,14 @@ pksetmask_LDADD = $(LDADD)
 pksetmask_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pksieve_OBJECTS = pksieve.$(OBJEXT)
 pksieve_OBJECTS = $(am_pksieve_OBJECTS)
 pksieve_LDADD = $(LDADD)
 pksieve_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 	$(top_builddir)/src/algorithms/libalgorithms.la \
 	$(top_builddir)/src/imageclasses/libimageClasses.la \
-	$(top_builddir)/src/fileclasses/libfileClasses.la \
-	$(top_builddir)/src/base/libbase.la
+	$(top_builddir)/src/fileclasses/libfileClasses.la
 am_pkstatascii_OBJECTS = pkstatascii.$(OBJEXT)
 pkstatascii_OBJECTS = $(am_pkstatascii_OBJECTS)
 pkstatascii_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
@@ -437,7 +422,7 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(GDAL_CFLAGS) @AM_CXXFLAGS@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-AM_LDFLAGS = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la $(top_builddir)/src/base/libbase.la @AM_LDFLAGS@
+AM_LDFLAGS = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la @AM_LDFLAGS@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -574,7 +559,7 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-LDADD = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la $(top_builddir)/src/base/libbase.la
+LDADD = $(GSL_LIBS) $(GDAL_LDFLAGS) $(top_builddir)/src/algorithms/libalgorithms.la $(top_builddir)/src/imageclasses/libimageClasses.la $(top_builddir)/src/fileclasses/libfileClasses.la
 @USE_FANN_TRUE at pkann_SOURCES = $(top_srcdir)/src/algorithms/myfann_cpp.h pkann.cc
 @USE_FANN_TRUE at pkann_CXXFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/base $(FANN_CFLAGS) -I$(top_srcdir)/src/algorithms $(AM_CXXFLAGS)
 @USE_FANN_TRUE at pkann_LDADD = $(FANN_LIBS) $(FANN_CFLAGS) $(AM_LDFLAGS) -lgsl
diff --git a/src/apps/pkann.cc b/src/apps/pkann.cc
index 64c34e4..b8d2ec5 100644
--- a/src/apps/pkann.cc
+++ b/src/apps/pkann.cc
@@ -46,15 +46,15 @@ int main(int argc, char *argv[])
   Optionpk<bool> random_opt("random", "random", "in case of balance, randomize input data", true,2);
   Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account (0: consider all classes)", 0);
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
-  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
-  Optionpk<double> bend_opt("be", "bend", "end band sequence number (set to 0 to include bands)", 0); 
+  Optionpk<double> bstart_opt("s", "start", "start band sequence number",0); 
+  Optionpk<double> bend_opt("e", "end", "end band sequence number (set to 0 to include bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<unsigned short> aggreg_opt("a", "aggreg", "how to combine aggregated classifiers, see also rc option (1: sum rule, 2: max rule).",1);
-  Optionpk<double> priors_opt("p", "prior", "prior probabilities for each class (e.g., -p 0.3 -p 0.3 -p 0.2 )", 0.0); 
+  Optionpk<double> priors_opt("prior", "prior", "prior probabilities for each class (e.g., -p 0.3 -p 0.3 -p 0.2 )", 0.0); 
   Optionpk<string> priorimg_opt("pim", "priorimg", "prior probability image (multi-band img with band for each class","",2); 
   Optionpk<unsigned short> cv_opt("cv", "cv", "n-fold cross validation mode",0);
-  Optionpk<unsigned int> nneuron_opt("n", "nneuron", "number of neurons in hidden layers in neural network (multiple hidden layers are set by defining multiple number of neurons: -n 15 -n 1, default is one hidden layer with 5 neurons)", 5); 
+  Optionpk<unsigned int> nneuron_opt("nn", "nneuron", "number of neurons in hidden layers in neural network (multiple hidden layers are set by defining multiple number of neurons: -n 15 -n 1, default is one hidden layer with 5 neurons)", 5); 
   Optionpk<float> connection_opt("\0", "connection", "connection reate (default: 1.0 for a fully connected network)", 1.0); 
   Optionpk<float> weights_opt("w", "weights", "weights for neural network. Apply to fully connected network only, starting from first input neuron to last output neuron, including the bias neurons (last neuron in each but last layer)", 0.0); 
   Optionpk<float> learning_opt("l", "learning", "learning rate (default: 0.7)", 0.7); 
@@ -610,10 +610,8 @@ int main(int argc, char *argv[])
     if(mask_opt.size()){
       try{
         if(verbose_opt[0]>=1)
-          cout << "opening mask image file " << mask_opt[0] << endl;
+          std::cout << "opening mask image file " << mask_opt[0] << std::endl;
         maskReader.open(mask_opt[0]);
-        assert(maskReader.nrOfCol()==testImage.nrOfCol());
-        assert(maskReader.nrOfRow()==testImage.nrOfRow());
       }
       catch(string error){
         cerr << error << endl;
@@ -745,20 +743,6 @@ int main(int argc, char *argv[])
       assert(nband==hpixel[0].size());
       if(verbose_opt[0]==2)
         cout << "used bands: " << nband << endl;
-      //read mask
-      if(!lineMask.empty()){
-        try{
-          maskReader.readData(lineMask,GDT_Int16,iline);
-        }
-        catch(string theError){
-          cerr << "Error reading " << mask_opt[0] << ": " << theError << endl;
-          exit(3);
-        }
-        catch(...){
-          cerr << "error catched" << endl;
-          exit(3);
-        }
-      }
       //read prior
       if(priorimg_opt.size()){
         try{
@@ -777,40 +761,70 @@ int main(int argc, char *argv[])
           exit(3);
         }
       }
-    
+      double oldRowMask=-1;//keep track of row mask to optimize number of line readings
       //process per pixel
       for(int icol=0;icol<ncol;++icol){
         assert(hpixel[icol].size()==nband);
         bool masked=false;
-        if(!lineMask.empty()){
-          short theMask=0;
-          for(short ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-            if(msknodata_opt[ivalue]>=0){//values set in msknodata_opt are invalid
-              if(lineMask[icol]==msknodata_opt[ivalue]){
-                theMask=lineMask[icol];
-                masked=true;
-                break;
-              }
-            }
-            else{//only values set in msknodata_opt are valid
-              if(lineMask[icol]!=-msknodata_opt[ivalue]){
-                  theMask=(nodata_opt.size()==msknodata_opt.size())? nodata_opt[ivalue] : nodata_opt[0];// lineMask[icol];
-                masked=true;
-              }
-              else{
-                masked=false;
-                break;
-              }
-            }
-          }
-          if(masked){
-            if(classBag_opt.size())
-              for(int ibag=0;ibag<nbag;++ibag)
-                classBag[ibag][icol]=theMask;
-            classOut[icol]=theMask;
-            continue;
-          }
-        }
+        if(mask_opt.size()){
+	  //read mask
+	  double colMask=0;
+	  double rowMask=0;
+	  double geox=0;
+	  double geoy=0;
+
+	  testImage.image2geo(icol,iline,geox,geoy);
+	  maskReader.geo2image(geox,geoy,colMask,rowMask);
+	  colMask=static_cast<int>(colMask);
+	  rowMask=static_cast<int>(rowMask);
+	  if(rowMask>=0&&rowMask<maskReader.nrOfRow()&&colMask>=0&&colMask<maskReader.nrOfCol()){
+	    if(static_cast<int>(rowMask)!=static_cast<int>(oldRowMask)){
+	      assert(rowMask>=0&&rowMask<maskReader.nrOfRow());
+	      try{
+		// maskReader.readData(lineMask[imask],GDT_Int32,static_cast<int>(rowMask));
+		maskReader.readData(lineMask,GDT_Int16,static_cast<int>(rowMask));
+	      }
+	      catch(string errorstring){
+		cerr << errorstring << endl;
+		exit(1);
+	      }
+	      catch(...){
+		cerr << "error catched" << std::endl;
+		exit(3);
+	      }
+	      oldRowMask=rowMask;
+	    }
+	  }
+	  else
+	    continue;//no coverage in this mask
+	  short theMask=0;
+	  for(short ivalue=0;ivalue<msknodata_opt.size();++ivalue){
+	    if(msknodata_opt[ivalue]>=0){//values set in msknodata_opt are invalid
+	      if(lineMask[colMask]==msknodata_opt[ivalue]){
+		theMask=lineMask[colMask];
+		masked=true;
+		break;
+	      }
+	    }
+	    else{//only values set in msknodata_opt are valid
+	      if(lineMask[colMask]!=-msknodata_opt[ivalue]){
+		theMask=lineMask[colMask];
+		masked=true;
+	      }
+	      else{
+		masked=false;
+		break;
+	      }
+	    }
+	  }
+	  if(masked){
+	    if(classBag_opt.size())
+	      for(int ibag=0;ibag<nbag;++ibag)
+		classBag[ibag][icol]=theMask;
+	    classOut[icol]=theMask;
+	    continue;
+	  }
+	}
         bool valid=false;
         for(int iband=0;iband<nband;++iband){
           if(hpixel[icol][iband]){
diff --git a/src/apps/pkascii2ogr.cc b/src/apps/pkascii2ogr.cc
index 47989b3..ddc648b 100644
--- a/src/apps/pkascii2ogr.cc
+++ b/src/apps/pkascii2ogr.cc
@@ -35,7 +35,6 @@ int main(int argc, char *argv[])
   Optionpk<bool> polygon_opt("l", "line", "create OGRPolygon as geometry instead of points.  Fields are taken from first point and polygon is automatically closed (no need to repeat first point at last line). (false: use OGRPoint)", false);
   Optionpk<string> fname_opt("n", "name", "Field names for the columns in the input ascii file");
   Optionpk<string> ftype_opt("ot", "ot", "Field type (Real, Integer, String) for each of the fields as defined by name","Real");
-  Optionpk<string> itype_opt("of", "of", "image type string", "ESRI Shapefile");
   Optionpk<string> projection_opt("a_srs", "a_srs", "Override the projection for the output file, use epsg:<code> or Wkt string", "epsg:4326");
   Optionpk<char> fs_opt("fs","fs","field separator.",' ');
   Optionpk<int> verbose_opt("v", "verbose", "verbose (0)", 0);
@@ -50,7 +49,6 @@ int main(int argc, char *argv[])
     polygon_opt.retrieveOption(argc,argv);
     fname_opt.retrieveOption(argc,argv);
     ftype_opt.retrieveOption(argc,argv);
-    itype_opt.retrieveOption(argc,argv);
     projection_opt.retrieveOption(argc,argv);
     fs_opt.retrieveOption(argc,argv);
     verbose_opt.retrieveOption(argc,argv);
diff --git a/src/apps/pkdumpimg.cc b/src/apps/pkdumpimg.cc
index 3cae28f..e763d86 100644
--- a/src/apps/pkdumpimg.cc
+++ b/src/apps/pkdumpimg.cc
@@ -37,7 +37,6 @@ int main(int argc, char *argv[])
 {
   Optionpk<std::string> input_opt("i","input","input image file","");
   Optionpk<string> output_opt("o", "output", "Output ascii file (Default is empty: use stdout", "");
-  Optionpk<string> otype_opt("ot", "otype", "Data type for output ({Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFloat64}). Empty string: inherit type from input image", "");
   Optionpk<string> oformat_opt("of", "oformat", "Output format (matrix form or list (x,y,z) form. Default is matrix form", "matrix");
   Optionpk<int> band_opt("b", "band", "band index to crop");
   Optionpk<string> extent_opt("e", "extent", "get boundary from extent from polygons in vector file", "");
@@ -48,7 +47,7 @@ int main(int argc, char *argv[])
   Optionpk<double> dx_opt("dx", "dx", "Output resolution in x (in meter) (0.0: keep original resolution)",0.0);
   Optionpk<double> dy_opt("dy", "dy", "Output resolution in y (in meter) (0.0: keep original resolution)",0.0);
   Optionpk<string> resample_opt("r", "resampling-method", "Resampling method (near: nearest neighbour, bilinear: bi-linear interpolation).", "near");
-  Optionpk<short> dstnodata_opt("dstnodata", "dstnodata", "nodata value for ouptut if out of bounds.", 0);
+  Optionpk<short> dstnodata_opt("dstnodata", "dstnodata", "nodata value for output if out of bounds.", 0);
   Optionpk<double> srcnodata_opt("srcnodata", "srcnodata", "set no data value(s) for input image");
   Optionpk<short> verbose_opt("v", "verbose", "verbose (Default: 0)", 0);
 
@@ -56,7 +55,6 @@ int main(int argc, char *argv[])
   try{
     doProcess=input_opt.retrieveOption(argc,argv);
     output_opt.retrieveOption(argc,argv);
-    otype_opt.retrieveOption(argc,argv);
     oformat_opt.retrieveOption(argc,argv);
     band_opt.retrieveOption(argc,argv);
     extent_opt.retrieveOption(argc,argv);
@@ -81,7 +79,7 @@ int main(int argc, char *argv[])
   }
 
   ofstream outputStream;
-  if(!output_opt[0].empty())
+  if(!output_opt.empty())
     outputStream.open(output_opt[0].c_str());
   
   RESAMPLE theResample;
@@ -100,14 +98,19 @@ int main(int argc, char *argv[])
     exit(1);
   }
 
-  ImgWriterGdal imgWriter;
+  // ImgWriterGdal imgWriter;
   GDALDataType theType;
 
+  if(input_opt.empty()){
+    std::cerr << "No input file provided (use option -i). Use --help for help information" << std::endl;
+    exit(0);
+  }
+
   ImgReaderGdal imgReader(input_opt[0]);
   for(int inodata=0;inodata<srcnodata_opt.size();++inodata)
     imgReader.pushNoDataValue(srcnodata_opt[inodata]);
 
-  ImgWriterGdal virtualWriter;//only for coordinate conversion (no output file defined)
+  // ImgWriterGdal virtualWriter;//only for coordinate conversion (no output file defined)
   
   int nband=imgReader.nrOfBand();
   //get number of lines
@@ -206,7 +209,7 @@ int main(int argc, char *argv[])
   }
   double gt[6];
   imgReader.getGeoTransform(gt);
-  imgWriter.setGeoTransform(gt);
+  // imgWriter.setGeoTransform(gt);
   // imgWriter.setProjection(imgReader.getProjection());
 
   double readRow=0;
@@ -231,7 +234,8 @@ int main(int argc, char *argv[])
       double x=0;
       double y=0;
       //convert irow to geo
-      imgWriter.image2geo(0,irow,x,y);
+      // imgWriter.image2geo(0,irow,x,y);
+      imgReader.image2geo(0,irow,x,y);
       //lookup corresponding row for irow in this file
       imgReader.geo2image(x,y,readCol,readRow);
       if(readRow<0||readRow>=imgReader.nrOfRow()){
@@ -247,7 +251,8 @@ int main(int argc, char *argv[])
         else
           imgReader.readData(readBuffer,GDT_Float64,startCol,endCol,readRow,band_opt[iband],theResample);
         for(int ib=0;ib<ncropcol;++ib){
-          assert(imgWriter.image2geo(ib,irow,x,y));
+          // assert(imgWriter.image2geo(ib,irow,x,y));
+          assert(imgReader.image2geo(ib,irow,x,y));
           //lookup corresponding row for irow in this file
           imgReader.geo2image(x,y,readCol,readRow);
           if(readCol<0||readCol>=imgReader.nrOfCol()){
diff --git a/src/apps/pkegcs.cc b/src/apps/pkegcs.cc
index 6d772fd..77f4234 100644
--- a/src/apps/pkegcs.cc
+++ b/src/apps/pkegcs.cc
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
   Optionpk<unsigned short>  band_opt("b", "band", "Band specific information", 0);
   Optionpk<std::string> cell2bb_opt("c2b","cell2bb","convert cell code to geo coordinates of boundingbox (e.g. 32-AB)","");
   Optionpk<std::string> cell2mid_opt("c2m","cell2mid","convert cell code to centre in geo coordinates (e.g. 32-AB)","");
-  Optionpk<bool> refpixel_opt("\0", "ref", "get reference pixel (lower left corner of centre of gravity pixel)", false);
+  Optionpk<bool> refpixel_opt("ref", "ref", "get reference pixel (lower left corner of centre of gravity pixel)", false);
   Optionpk<double> maskValue_opt("m", "mask", "mask value(s) for no data to calculate reference pixel in image",0);
   Optionpk<int> dx_opt("dx","dx","resolution",250);
   Optionpk<bool> geo2cell_opt("g2c", "geo2cell", "get cell code for coordinates in x_opt and y_opt given the resolution in dx_opt", false);
diff --git a/src/apps/pkextract.cc b/src/apps/pkextract.cc
index 8ec5bd6..e65124f 100644
--- a/src/apps/pkextract.cc
+++ b/src/apps/pkextract.cc
@@ -421,7 +421,7 @@ int main(int argc, char *argv[])
 		  continue;//do not select for now, go to next column
               }
               else if(nvalid.size()>processClass){//absolute value
-                if(nvalid[processClass]>-theThreshold)
+                if(nvalid[processClass]>=-theThreshold)
                   continue;//do not select any more pixels for this class, go to next column to search for other classes
               }
 	      writeBuffer.push_back(sample);
@@ -614,7 +614,7 @@ int main(int argc, char *argv[])
                   continue;//do not select for now, go to next column
               }
               else if(nvalid.size()>processClass){//absolute value
-                if(nvalid[processClass]>-theThreshold)
+                if(nvalid[processClass]>=-theThreshold)
                   continue;//do not select any more pixels for this class, go to next column to search for other classes
               }
               writeBuffer.push_back(sample);
@@ -812,7 +812,7 @@ int main(int argc, char *argv[])
 	  }
 	}
 	else{//absolute value
-	  if(ntotalvalid>-threshold_opt[0]){
+	  if(ntotalvalid>=-threshold_opt[0]){
 	    if(test_opt.size())
 	      writeTest=true;
 	    else
@@ -1025,12 +1025,17 @@ int main(int argc, char *argv[])
 		      writePointFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
 		    if(verbose_opt[0]>1)
 		      std::cout << "copying fields from polygons " << std::endl;
+		    //Geometry of readFeature and writePointFeature are both wkbPoint
+		    //attributes AND geometry are copied with SetFrom
+		    //test
+		    // writePointFeature->SetGeometry(&thePoint);
 		    if(writePointFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		      cerr << "writing feature failed" << std::endl;
-		    writePointFeature->SetGeometry(&thePoint);
-		    OGRGeometry *updateGeometry;
-		    updateGeometry = writePointFeature->GetGeometryRef();
-		    OGRPoint *poPoint = (OGRPoint *) updateGeometry;
+
+		    assert(wkbFlatten(writePointFeature->GetGeometryRef()->getGeometryType()) == wkbPoint);
+		    // OGRGeometry *updateGeometry;
+		    // updateGeometry = writePointFeature->GetGeometryRef();
+		    // OGRPoint *poPoint = (OGRPoint *) updateGeometry;
 		    if(verbose_opt[0]>1)
 		      std::cout << "write feature has " << writePointFeature->GetFieldCount() << " fields" << std::endl;
 		  }
@@ -1057,19 +1062,26 @@ int main(int argc, char *argv[])
 		      windowValues[iband].push_back(value);
 		    }
 		    else{
-		      if(verbose_opt[0]>1)
-			std::cout << "set field " << fieldname_opt[iband] << " to " << value << std::endl;
-		      switch( fieldType ){
-		      case OFTInteger:
-		      case OFTReal:
-			writePointFeature->SetField(fieldname_opt[iband].c_str(),value);
-			break;
-		      case OFTString:
-			writePointFeature->SetField(fieldname_opt[iband].c_str(),type2string<double>(value).c_str());
-			break;
-		      default://not supported
-			assert(0);
-			break;
+		      try{
+			if(verbose_opt[0]>1)
+			  std::cout << "set field " << fieldname_opt[iband] << " to " << value << std::endl;
+			switch( fieldType ){
+			case OFTInteger:
+			case OFTReal:
+			  writePointFeature->SetField(fieldname_opt[iband].c_str(),value);
+			  break;
+			case OFTString:
+			  writePointFeature->SetField(fieldname_opt[iband].c_str(),type2string<double>(value).c_str());
+			  break;
+			default://not supported
+			  std::string errorString="field type not supported";
+			  throw(errorString);
+			  break;
+			}
+		      }
+		      catch(std::string e){
+			std::cout << e << std::endl;
+			exit(1);
 		      }
 		    }//else
 		  }//iband
@@ -1091,7 +1103,7 @@ int main(int argc, char *argv[])
 			throw(errorString);
 		      }
 		    }
-		    //destroy feature
+ 		    //destroy feature
 		    OGRFeature::DestroyFeature( writePointFeature );
 		    ++ntotalvalid;
 		    if(verbose_opt[0])
@@ -1112,9 +1124,14 @@ int main(int argc, char *argv[])
 		// writePolygon.addRing(&writeRing);//already done
 		// writePolygon.closeRings();//already done
 		//write geometry of writePolygon
+		//test
+		// writePolygonFeature->SetGeometry(&writePolygon);
 		if(writePolygonFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
+		//test
 		writePolygonFeature->SetGeometry(&writePolygon);
+		assert(wkbFlatten(writePolygonFeature->GetGeometryRef()->getGeometryType()) == wkbPolygon);
+
 		if(verbose_opt[0]>1)
 		  std::cout << "copying new fields write polygon " << std::endl;
 		if(verbose_opt[0]>1)
@@ -1125,12 +1142,17 @@ int main(int argc, char *argv[])
 		//create feature
 		if(verbose_opt[0]>1)
 		  std::cout << "copying fields from polygons " << std::endl;
+		//test
+		//Geometry of readFeature and writeCentroidFeature are both wkbPoint
+		//attributes AND geometry are copied with SetFrom
+		// writeCentroidFeature->SetGeometry(&writeCentroidPoint);
 		if(writeCentroidFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
-		writeCentroidFeature->SetGeometry(&writeCentroidPoint);
-		OGRGeometry *updateGeometry;
-		updateGeometry = writeCentroidFeature->GetGeometryRef();
-		assert(wkbFlatten(updateGeometry->getGeometryType()) == wkbPoint );
+		assert(wkbFlatten(writeCentroidFeature->GetGeometryRef()->getGeometryType()) == wkbPoint);
+		//test
+		// OGRGeometry *updateGeometry;
+		// updateGeometry = writeCentroidFeature->GetGeometryRef();
+		// assert(wkbFlatten(updateGeometry->getGeometryType()) == wkbPoint );
 		if(verbose_opt[0]>1)
 		  std::cout << "write feature has " << writeCentroidFeature->GetFieldCount() << " fields" << std::endl;
 	      }
@@ -1150,72 +1172,91 @@ int main(int argc, char *argv[])
 		      std::cout << "number of points in window: " << nPointWindow << std::endl;
 		    int theBand=(band_opt.size()) ? band_opt[index] : index;
 
-		    if(verbose_opt[0]>1)
-		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
-		    switch( fieldType ){
-		    case OFTInteger:
-		    case OFTReal:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      break;
-		    case OFTString:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      break;
-		    default://not supported
-		      std::cout << "field type not supported yet..." << std::endl;
-		      break;
+		    try{
+		      if(verbose_opt[0]>1)
+			std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		      switch( fieldType ){
+		      case OFTInteger:
+		      case OFTReal:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			break;
+		      case OFTString:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			break;
+		      default://not supported
+			std::string errorString="field type not supported";
+			throw(errorString);
+			break;
+		      }
+		    }
+		    catch(std::string e){
+		      std::cout << e << std::endl;
+		      exit(1);
 		    }
 		  }
 		}
 		else{//ruleMap[rule_opt[0]] is not rule::point
 		  double theValue=0;
 		  for(int index=0;index<windowValues.size();++index){
-		    if(windowValues[index].size()!=buffer_opt[0]*buffer_opt[0]){
-		      cerr << "Error: windowValues[index].size()=" << windowValues[index].size() << endl;
-		    }
-		    if(ruleMap[rule_opt[0]]==rule::mean)
-		      theValue=stat.mean(windowValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::stdev)
-		      theValue=sqrt(stat.var(windowValues[index]));
-		    else if(ruleMap[rule_opt[0]]==rule::median)
-		      theValue=stat.median(windowValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::sum)
-		      theValue=stat.sum(windowValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::max)
-		      theValue=stat.mymax(windowValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::min)
-		      theValue=stat.mymin(windowValues[index]);
-		    else{//rule::centroid
-		      if(verbose_opt[0])
-			std::cout << "number of points in polygon: " << nPointWindow << std::endl;
-		      assert(nPointWindow<=1);
-		      assert(nPointWindow==windowValues[index].size());
-		      theValue=windowValues[index].back();
+		    try{
+		      if(windowValues[index].size()!=buffer_opt[0]*buffer_opt[0]){
+			std::string errorString="windowValues[index].size()!=buffer*buffer";
+			throw(errorString);
+		      }
+		      if(ruleMap[rule_opt[0]]==rule::mean)
+			theValue=stat.mean(windowValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::stdev)
+			theValue=sqrt(stat.var(windowValues[index]));
+		      else if(ruleMap[rule_opt[0]]==rule::median)
+			theValue=stat.median(windowValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::sum)
+			theValue=stat.sum(windowValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::max)
+			theValue=stat.mymax(windowValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::min)
+			theValue=stat.mymin(windowValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::centroid){
+			if(verbose_opt[0])
+			  std::cout << "number of points in polygon: " << nPointWindow << std::endl;
+			assert(nPointWindow<=1);
+			assert(nPointWindow==windowValues[index].size());
+			theValue=windowValues[index].back();
+		      }
+		      else{
+			std::string errorString="rule not supported";
+			throw(errorString);
+		      }
+		      if(verbose_opt[0]>1)
+			std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		      switch( fieldType ){
+		      case OFTInteger:
+		      case OFTReal:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			break;
+		      case OFTString:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			break;
+		      default://not supported
+			std::string errorString="field type not supported";
+			throw(errorString);
+			break;
+		      }
 		    }
-		    if(verbose_opt[0]>1)
-		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
-		    switch( fieldType ){
-		    case OFTInteger:
-		    case OFTReal:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      break;
-		    case OFTString:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      break;
-		    default://not supported
-		      std::cout << "field type not supported yet..." << std::endl;
-		      break;
+		    catch(std::string e){
+		      std::cout << e << std::endl;
+		      exit(1);
 		    }
 		  }
 		}
@@ -1475,6 +1516,8 @@ int main(int argc, char *argv[])
 		  validFeature=true;
 
 		writeRing.addPoint(&thePoint);//todo: check if I need to add all interior points to ring or do I need to check if point is on ring first?
+		// if(writeRing.isPointOnRingBoundary(&thePoint))
+		//    writeRing.addPoint(&thePoint);
 		if(verbose_opt[0]>1)
 		  std::cout << "point is on surface:" << thePoint.getX() << "," << thePoint.getY() << std::endl;
 		++nPointPolygon;
@@ -1493,12 +1536,17 @@ int main(int argc, char *argv[])
 		      writePointFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
 		    if(verbose_opt[0]>1)
 		      std::cout << "copying fields from polygons " << std::endl;
+		    //test
+		    // writePointFeature->SetGeometry(&thePoint);
 		    if(writePointFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		      cerr << "writing feature failed" << std::endl;
+		    //test
 		    writePointFeature->SetGeometry(&thePoint);
-		    OGRGeometry *updateGeometry;
-		    updateGeometry = writePointFeature->GetGeometryRef();
-		    OGRPoint *poPoint = (OGRPoint *) updateGeometry;
+		    assert(wkbFlatten(writePolygonFeature->GetGeometryRef()->getGeometryType()) == wkbPoint);
+		    //test
+		    // OGRGeometry *updateGeometry;
+		    // updateGeometry = writePointFeature->GetGeometryRef();
+		    // OGRPoint *poPoint = (OGRPoint *) updateGeometry;
 		    if(verbose_opt[0]>1)
 		      std::cout << "write feature has " << writePointFeature->GetFieldCount() << " fields" << std::endl;
 		  }
@@ -1579,9 +1627,11 @@ int main(int argc, char *argv[])
 		writePolygon.addRing(&writeRing);
 		writePolygon.closeRings();
 		//write geometry of writePolygon
+		//test
+		//writePolygonFeature and readFeature are both of type wkbPolygon
+		// writePolygonFeature->SetGeometry(&writePolygon);
 		if(writePolygonFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
-		writePolygonFeature->SetGeometry(&writePolygon);
 		if(verbose_opt[0]>1)
 		  std::cout << "copying new fields write polygon " << std::endl;
 		if(verbose_opt[0]>1)
@@ -1592,12 +1642,16 @@ int main(int argc, char *argv[])
 		//create feature
 		if(verbose_opt[0]>1)
 		  std::cout << "copying fields from polygons " << std::endl;
+		//test
+		//writeCentroidFeature->SetGeometry(&writeCentroidPoint);
 		if(writeCentroidFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
+		//test
 		writeCentroidFeature->SetGeometry(&writeCentroidPoint);
-		OGRGeometry *updateGeometry;
-		updateGeometry = writeCentroidFeature->GetGeometryRef();
-		assert(wkbFlatten(updateGeometry->getGeometryType()) == wkbPoint );
+		assert(wkbFlatten(writeCentroidFeature->GetGeometryRef()->getGeometryType()) == wkbPoint );
+		// OGRGeometry *updateGeometry;
+		// updateGeometry = writeCentroidFeature->GetGeometryRef();
+		// assert(wkbFlatten(updateGeometry->getGeometryType()) == wkbPoint );
 		if(verbose_opt[0]>1)
 		  std::cout << "write feature has " << writeCentroidFeature->GetFieldCount() << " fields" << std::endl;
 	      }
@@ -1606,77 +1660,93 @@ int main(int argc, char *argv[])
 		  if(verbose_opt[0])
 		    std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
 		  for(int index=0;index<polyValues.size();++index){
-		    //test
 		    assert(polyValues[index].size()==1);
 		    double theValue=polyValues[index].back();
 
 		    if(verbose_opt[0])
 		      std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
 		    int theBand=(band_opt.size()) ? band_opt[index] : index;
-
-		    if(verbose_opt[0]>1)
-		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
-		    switch( fieldType ){
-		    case OFTInteger:
-		    case OFTReal:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      break;
-		    case OFTString:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      break;
-		    default://not supported
-		      std::cout << "field type not supported yet..." << std::endl;
-		      break;
+		    try{
+		      if(verbose_opt[0]>1)
+			std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		      switch( fieldType ){
+		      case OFTInteger:
+		      case OFTReal:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			break;
+		      case OFTString:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			break;
+		      default://not supported
+			std::string errorString="field type not supported";
+			throw(errorString);
+			break;
+		      }
+		    }
+		    catch(std::string e){
+		      std::cout << e << std::endl;
+		      exit(1);
 		    }
 		  }
 		}
 		else{//ruleMap[rule_opt[0]] is not rule::point
 		  double theValue=0;
 		  for(int index=0;index<polyValues.size();++index){
-		    if(ruleMap[rule_opt[0]]==rule::mean)
-		      theValue=stat.mean(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::stdev)
-		      theValue=sqrt(stat.var(polyValues[index]));
-		    else if(ruleMap[rule_opt[0]]==rule::median)
-		      theValue=stat.median(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::sum)
-		      theValue=stat.sum(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::max)
-		      theValue=stat.mymax(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::min)
-		      theValue=stat.mymin(polyValues[index]);
-		    else{//rule::centroid
-		      if(verbose_opt[0])
-			std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
-		      assert(nPointPolygon<=1);
-		      assert(nPointPolygon==polyValues[index].size());
-		      theValue=polyValues[index].back();
+		    try{
+		      if(ruleMap[rule_opt[0]]==rule::mean)
+			theValue=stat.mean(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::stdev)
+			theValue=sqrt(stat.var(polyValues[index]));
+		      else if(ruleMap[rule_opt[0]]==rule::median)
+			theValue=stat.median(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::sum)
+			theValue=stat.sum(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::max)
+			theValue=stat.mymax(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::min)
+			theValue=stat.mymin(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::centroid){
+			if(verbose_opt[0])
+			  std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
+			assert(nPointPolygon<=1);
+			assert(nPointPolygon==polyValues[index].size());
+			theValue=polyValues[index].back();
+		      }
+		      else{
+			std::string errorString="rule not supported";
+			throw(errorString);
+		      }
+		      if(verbose_opt[0]>1)
+			std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		      switch( fieldType ){
+		      case OFTInteger:
+		      case OFTReal:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			break;
+		      case OFTString:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			break;
+		      default:
+			std::string errorString="field type not supported";
+			throw(errorString);
+			break;
+		      }
 		    }
-		    if(verbose_opt[0]>1)
-		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
-		    switch( fieldType ){
-		    case OFTInteger:
-		    case OFTReal:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      break;
-		    case OFTString:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      break;
-		    default://not supported
-		      std::cout << "field type not supported yet..." << std::endl;
-		      break;
+		    catch(std::string e){
+		      std::cout << e << std::endl;
+		      exit(1);
 		    }
 		  }
 		}
@@ -1931,6 +2001,8 @@ int main(int argc, char *argv[])
 		  validFeature=true;
 		
 		writeRing.addPoint(&thePoint);
+		// if(writeRing.isPointOnRingBoundary(&thePoint))
+		//    writeRing.addPoint(&thePoint);
 		if(verbose_opt[0]>1)
 		    std::cout << "point is on surface:" << thePoint.getX() << "," << thePoint.getY() << std::endl;
 		  ++nPointPolygon;
@@ -1949,12 +2021,16 @@ int main(int argc, char *argv[])
 			writePointFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn());
 		      if(verbose_opt[0]>1)
 			std::cout << "copying fields from polygons " << std::endl;
+		      //test
+		      // writePointFeature->SetGeometry(&thePoint);
 		      if(writePointFeature->SetFrom(readFeature)!= OGRERR_NONE)
 			cerr << "writing feature failed" << std::endl;
+		      //test
 		      writePointFeature->SetGeometry(&thePoint);
-		      OGRGeometry *updateGeometry;
-		      updateGeometry = writePointFeature->GetGeometryRef();
-		      OGRPoint *poPoint = (OGRPoint *) updateGeometry;
+		      assert(wkbFlatten(writePolygonFeature->GetGeometryRef()->getGeometryType()) == wkbPoint);
+		      // OGRGeometry *updateGeometry;
+		      // updateGeometry = writePointFeature->GetGeometryRef();
+		      // OGRPoint *poPoint = (OGRPoint *) updateGeometry;
 		      if(verbose_opt[0]>1)
 			std::cout << "write feature has " << writePointFeature->GetFieldCount() << " fields" << std::endl;
 		    }
@@ -2035,8 +2111,6 @@ int main(int argc, char *argv[])
 		    std::cout << "ntotalvalid: " << ntotalvalid << std::endl;
 	      }
 	    }
-
-	    //test
 	    if(!validFeature)
 	      continue;
 	    if(polygon_opt[0]||ruleMap[rule_opt[0]]!=rule::point){
@@ -2048,25 +2122,32 @@ int main(int argc, char *argv[])
 		writePolygon.addRing(&writeRing);
 		writePolygon.closeRings();
 		//write geometry of writePolygon
+		//test
+		//writePolygon and readFeature are from geometry type wkbMultiPolygon
+		// writePolygonFeature->SetGeometry(&writePolygon);
 		if(writePolygonFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
-		writePolygonFeature->SetGeometry(&writePolygon);
+		assert(writePolygonFeature->GetGeometryRef()->getGeometryType()==wkbMultiPolygon);
 		if(verbose_opt[0]>1)
 		  std::cout << "copying new fields write polygon " << std::endl;
 		if(verbose_opt[0]>1)
 		  std::cout << "write feature has " << writePolygonFeature->GetFieldCount() << " fields" << std::endl;
 		//write polygon feature
 	      }
-	      else{//write mean /median value of polygon to centroid point (ruleMap[rule_opt[0]]==rule::mean, stdev or median )
+	      else{//write band information of polygon to centroid point
 		//create feature
 		if(verbose_opt[0]>1)
 		  std::cout << "copying fields from polygons " << std::endl;
+		//test
+		// writeCentroidFeature->SetGeometry(&writeCentroidPoint);
 		if(writeCentroidFeature->SetFrom(readFeature)!= OGRERR_NONE)
 		  cerr << "writing feature failed" << std::endl;
 		writeCentroidFeature->SetGeometry(&writeCentroidPoint);
-		OGRGeometry *updateGeometry;
-		updateGeometry = writeCentroidFeature->GetGeometryRef();
-		assert(wkbFlatten(updateGeometry->getGeometryType()) == wkbPoint );
+		assert(wkbFlatten(writeCentroidFeature->GetGeometryRef()->getGeometryType()) == wkbPoint);
+		//test
+		// OGRGeometry *updateGeometry;
+		// updateGeometry = writeCentroidFeature->GetGeometryRef();
+		// assert(wkbFlatten(updateGeometry->getGeometryType()) == wkbPoint );
 		if(verbose_opt[0]>1)
 		  std::cout << "write feature has " << writeCentroidFeature->GetFieldCount() << " fields" << std::endl;
 	      }
@@ -2081,120 +2162,87 @@ int main(int argc, char *argv[])
 		    if(verbose_opt[0])
 		      std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
 		    int theBand=(band_opt.size()) ? band_opt[index] : index;
-
-		    if(verbose_opt[0]>1)
-		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
-		    switch( fieldType ){
-		    case OFTInteger:
-		    case OFTReal:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      break;
-		    case OFTString:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      break;
-		      // case OFTRealList:{
-		      //   int fieldIndex;
-		      //   int nCount;
-		      //   const double *theList;
-		      //   vector<double> vectorList;
-		      //   if(polygon_opt[0]){
-		      //     fieldIndex=writePolygonFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //     theList=writePolygonFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //     vectorList.resize(nCount+1);
-		      //     for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //     vectorList[nCount]=theValue;
-		      //     writePolygonFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      //   }
-		      //   else{
-		      //     fieldIndex=writeCentroidFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //     theList=writeCentroidFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //     vectorList.resize(nCount+1);
-		      //     for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //     vectorList[nCount]=theValue;
-		      //     writeCentroidFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      //   }
-		      //   break;
-		      // }
-		    default://not supported
-		      std::cout << "field type not supported yet..." << std::endl;
-		      break;
+		    try{
+		      if(verbose_opt[0]>1)
+			std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		      switch( fieldType ){
+		      case OFTInteger:
+		      case OFTReal:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			break;
+		      case OFTString:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			break;
+		      default://not supported
+			std::string errorString="field type not supported";
+			throw(errorString);
+			break;
+		      }
+		    }
+		    catch(std::string e){
+		      std::cout << e << std::endl;
+		      exit(1);
 		    }
 		  }
 		}
 		else{//ruleMap[rule_opt[0]] is not rule::point
 		  double theValue=0;
 		  for(int index=0;index<polyValues.size();++index){
-		    if(ruleMap[rule_opt[0]]==rule::mean)
-		      theValue=stat.mean(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::stdev)
-		      theValue=sqrt(stat.var(polyValues[index]));
-		    else if(ruleMap[rule_opt[0]]==rule::median)
-		      theValue=stat.median(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::sum)
-		      theValue=stat.sum(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::max)
-		      theValue=stat.mymax(polyValues[index]);
-		    else if(ruleMap[rule_opt[0]]==rule::min)
-		      theValue=stat.mymin(polyValues[index]);
-		    else{//rule::centroid
-		      if(verbose_opt[0])
-			std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
-		      assert(nPointPolygon<=1);
-		      assert(nPointPolygon==polyValues[index].size());
-		      theValue=polyValues[index].back();
+		    try{
+		      if(ruleMap[rule_opt[0]]==rule::mean)
+			theValue=stat.mean(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::stdev)
+			theValue=sqrt(stat.var(polyValues[index]));
+		      else if(ruleMap[rule_opt[0]]==rule::median)
+			theValue=stat.median(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::sum)
+			theValue=stat.sum(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::max)
+			theValue=stat.mymax(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::min)
+			theValue=stat.mymin(polyValues[index]);
+		      else if(ruleMap[rule_opt[0]]==rule::centroid){
+			if(verbose_opt[0])
+			  std::cout << "number of points in polygon: " << nPointPolygon << std::endl;
+			assert(nPointPolygon<=1);
+			assert(nPointPolygon==polyValues[index].size());
+			theValue=polyValues[index].back();
+		      }
+		      else{
+			std::string errorString="rule not supported";
+			throw(errorString);
+		      }
+		      if(verbose_opt[0]>1)
+			std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
+		      switch( fieldType ){
+		      case OFTInteger:
+		      case OFTReal:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
+			break;
+		      case OFTString:
+			if(polygon_opt[0])
+			  writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			else
+			  writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
+			break;
+		      default://not supported
+			std::string errorString="field type not supported";
+			throw(errorString);
+			break;
+		      }
 		    }
-		    if(verbose_opt[0]>1)
-		      std::cout << "set field " << fieldname_opt[index] << " to " << theValue << std::endl;
-		    switch( fieldType ){
-		    case OFTInteger:
-		    case OFTReal:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),theValue);
-		      break;
-		    case OFTString:
-		      if(polygon_opt[0])
-			writePolygonFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      else
-			writeCentroidFeature->SetField(fieldname_opt[index].c_str(),type2string<double>(theValue).c_str());
-		      break;
-		      // case OFTRealList:{
-		      // int fieldIndex;
-		      // int nCount;
-		      // const double *theList;
-		      // vector<double> vectorList;
-		      // if(polygon_opt[0]){
-		      //   fieldIndex=writePolygonFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //   theList=writePolygonFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //   vectorList.resize(nCount+1);
-		      //   for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //   vectorList[nCount]=theValue;
-		      //   writePolygonFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      // }
-		      // else{
-		      //   fieldIndex=writeCentroidFeature->GetFieldIndex(fieldname_opt[index].c_str());
-		      //   theList=writeCentroidFeature->GetFieldAsDoubleList(fieldIndex,&nCount);
-		      //   vectorList.resize(nCount+1);
-		      //   for(int index=0;index<nCount;++index)
-		      // 	vectorList[index]=theList[index];
-		      //   vectorList[nCount]=theValue;
-		      //   writeCentroidFeature->SetField(fieldIndex,vectorList.size(),&(vectorList[0]));
-		      // }
-		      // break;
-		      // }
-		    default://not supported
-		      std::cout << "field type not supported yet..." << std::endl;
-		      break;
+		    catch(std::string e){
+		      std::cout << e << std::endl;
+		      exit(1);
 		    }
 		  }
 		}
diff --git a/src/apps/pkfilter.cc b/src/apps/pkfilter.cc
index 2645f1b..67489ad 100644
--- a/src/apps/pkfilter.cc
+++ b/src/apps/pkfilter.cc
@@ -51,7 +51,7 @@ int main(int argc,char **argv) {
   Optionpk<int> family_opt("wf", "family", "wavelet family (vanishing moment, see also http://www.gnu.org/software/gsl/manual/html_node/DWT-Initialization.html)", 4);
   Optionpk<short> class_opt("class", "class", "class value(s) to use for density, erosion, dilation, openening and closing, thresholding");
   Optionpk<double> threshold_opt("t", "threshold", "threshold value(s) to use for threshold filter (one for each class), or threshold to cut for dwt_cut (use 0 to keep all) or dwt_cut_from, or sigma for shift", 0);
-  Optionpk<short> nodata_opt("nodata", "nodata", "nodata value(s) for smoothnodata filter");
+  Optionpk<double> nodata_opt("nodata", "nodata", "nodata value(s) (used for smoothnodata filter)");
   Optionpk<std::string> tap_opt("tap", "tap", "text file containing taps used for spatial filtering (from ul to lr). Use dimX and dimY to specify tap dimensions in x and y. Leave empty for not using taps");
   Optionpk<double> tapz_opt("tapz", "tapz", "taps used for spectral filtering");
   Optionpk<string> padding_opt("pad","pad", "Padding method for filtering (how to handle edge effects). Choose between: symmetric, replicate, circular, constant (pad with 0).", "symmetric");
@@ -251,6 +251,7 @@ int main(int argc,char **argv) {
     for(int imask=0;imask<nodata_opt.size();++imask){
       if(verbose_opt[0])
         std::cout<< nodata_opt[imask] << " ";
+      filter1d.pushNoDataValue(nodata_opt[imask]);
       filter2d.pushNoDataValue(nodata_opt[imask]);
     }
     if(verbose_opt[0])
diff --git a/src/apps/pkfilterascii.cc b/src/apps/pkfilterascii.cc
index f6922a7..7e43e55 100644
--- a/src/apps/pkfilterascii.cc
+++ b/src/apps/pkfilterascii.cc
@@ -1,5 +1,5 @@
 /**********************************************************************
-pkfilterascii.cc: program to filter data in ASCII file (spectral respons function, dwt)
+pkfilterascii.cc: program to filter data in an ASCII file
 Copyright (C) 2008-2014 Pieter Kempeneers
 
 This file is part of pktools
diff --git a/src/apps/pkfilterdem.cc b/src/apps/pkfilterdem.cc
index a62c598..c2448dd 100644
--- a/src/apps/pkfilterdem.cc
+++ b/src/apps/pkfilterdem.cc
@@ -1,5 +1,5 @@
 /**********************************************************************
-pkfilterdem.cc: program to post filter raster images created with pklas2img
+pkfilterdem.cc: Filter digital elevation model raster datasets
 Copyright (C) 2008-2014 Pieter Kempeneers
 
 This file is part of pktools
@@ -36,7 +36,7 @@ int main(int argc,char **argv) {
   Optionpk<std::string> tmpdir_opt("tmp", "tmp", "Temporary directory","/tmp",2);
   Optionpk<bool> disc_opt("circ", "circular", "circular disc kernel for dilation and erosion", false);
   Optionpk<string> postFilter_opt("f", "filter", "post processing filter: vito, etew_min, promorph (progressive morphological filter),open,close).");
-  Optionpk<double> dim_opt("dim", "dim", "maximum filter kernel size (optionally you can set both initial and maximum filter kernel size", 3);
+  Optionpk<double> dim_opt("dim", "dim", "maximum filter kernel size", 17);
   Optionpk<double> maxSlope_opt("st", "st", "slope threshold used for morphological filtering. Use a low values to remove more height objects in flat terrains", 0.0);
   Optionpk<double> hThreshold_opt("ht", "ht", "initial height threshold for progressive morphological filtering. Use low values to remove more height objects. Optionally, a maximum height threshold can be set via a second argument (e.g., -ht 0.2 -ht 2.5 sets an initial threshold at 0.2 m and caps the threshold at 2.5 m).", 0.2);
   Optionpk<short> minChange_opt("minchange", "minchange", "Stop iterations when no more pixels are changed than this threshold.", 0);
@@ -44,7 +44,7 @@ int main(int argc,char **argv) {
   Optionpk<string>  oformat_opt("of", "oformat", "Output image format (see also gdal_translate). Empty string: inherit from input image");
   Optionpk<string>  colorTable_opt("ct", "ct", "color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid). Use none to ommit color table");
   Optionpk<string> option_opt("co", "co", "Creation option for output file. Multiple options can be specified.");
-  Optionpk<short> nodata_opt("nodata", "nodata", "nodata value(s) for smoothnodata filter");
+  Optionpk<short> nodata_opt("nodata", "nodata", "nodata value");
   Optionpk<short> verbose_opt("v", "verbose", "verbose mode if > 0", 0);
 
   bool doProcess;//stop process when program was invoked with help option (-h --help)
diff --git a/src/apps/pkfsann.cc b/src/apps/pkfsann.cc
index d155158..08946e5 100644
--- a/src/apps/pkfsann.cc
+++ b/src/apps/pkfsann.cc
@@ -180,8 +180,8 @@ int main(int argc, char *argv[])
   Optionpk<bool> random_opt("random","random", "in case of balance, randomize input data", true);
   Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account", 0);
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
-  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
-  Optionpk<double> bend_opt("be", "bend", "end band sequence number (set to 0 to include all bands)", 0); 
+  Optionpk<double> bstart_opt("s", "start", "start band sequence number",0); 
+  Optionpk<double> bend_opt("e", "end", "end band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<unsigned short> aggreg_opt("a", "aggreg", "how to combine aggregated classifiers, see also rc option (0: no aggregation, 1: sum rule, 2: max rule).",0);
diff --git a/src/apps/pkfssvm.cc b/src/apps/pkfssvm.cc
index 67c96d0..83caa76 100644
--- a/src/apps/pkfssvm.cc
+++ b/src/apps/pkfssvm.cc
@@ -206,8 +206,8 @@ int main(int argc, char *argv[])
   Optionpk<bool> random_opt("random","random", "in case of balance, randomize input data", true);
   Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account", 0);
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
-  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
-  Optionpk<double> bend_opt("be", "bend", "end band sequence number (set to 0 to include all bands)", 0); 
+  Optionpk<double> bstart_opt("s", "start", "start band sequence number",0); 
+  Optionpk<double> bend_opt("e", "end", "end band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<string> selector_opt("sm", "sm", "feature selection method (sffs=sequential floating forward search,sfs=sequential forward search, sbs, sequential backward search ,bfs=brute force search)","sffs"); 
diff --git a/src/apps/pkinfo.cc b/src/apps/pkinfo.cc
index 116456c..2978eed 100644
--- a/src/apps/pkinfo.cc
+++ b/src/apps/pkinfo.cc
@@ -1,5 +1,5 @@
 /**********************************************************************
-pkinfo.cc: program to retrieve information from raster images
+pkinfo.cc: Report basic information from raster datasets (similar to gdalinfo)
 Copyright (C) 2008-2014 Pieter Kempeneers
 
 This file is part of pktools
diff --git a/src/apps/pkkalman.cc b/src/apps/pkkalman.cc
index 24dd44b..be1de0f 100644
--- a/src/apps/pkkalman.cc
+++ b/src/apps/pkkalman.cc
@@ -621,8 +621,12 @@ int main(int argc,char **argv) {
 	      double obsMeanValue=statobs.mean(obsWindowBuffer);
 	      double difference=(obsMeanValue-c0obs)/c1obs-modValue;
 	      difference/=modValue;//make relative difference
-	      difference*=difference;
-	      doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
+	      if(deltaObs_opt[0]<0)
+		doUpdate=((100*difference)<deltaObs_opt[0]);
+	      else{
+		difference*=difference;
+		doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
+	      }
 	    }
 	    if(doUpdate){
 	      double kalmanGain=1;
@@ -1046,7 +1050,12 @@ int main(int argc,char **argv) {
 	      difference*=difference;
 	      difference/=modValue;//make relative difference
 	      difference*=difference;
-	      doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
+	      if(deltaObs_opt[0]<0)
+		doUpdate=((100*difference)<deltaObs_opt[0]);
+	      else{
+		difference*=difference;
+		doUpdate=(100*sqrt(difference)<deltaObs_opt[0]);
+	      }
 	    }
 	    if(doUpdate){
 	      double kalmanGain=1;
diff --git a/src/apps/pklas2img.cc b/src/apps/pklas2img.cc
index 5cf97f8..ff6f542 100644
--- a/src/apps/pklas2img.cc
+++ b/src/apps/pklas2img.cc
@@ -1,5 +1,5 @@
 /**********************************************************************
-pklas2img.cc: program to create (e.g., DEM) raster image from las files
+pklas2img.cc: Rasterize LAS/LAZ point clouds with filtering/compositing options
 Copyright (C) 2008-2014 Pieter Kempeneers
 
 This file is part of pktools
diff --git a/src/apps/pkoptsvm.cc b/src/apps/pkoptsvm.cc
index 0452469..2463237 100644
--- a/src/apps/pkoptsvm.cc
+++ b/src/apps/pkoptsvm.cc
@@ -267,8 +267,8 @@ int main(int argc, char *argv[])
   Optionpk<bool> random_opt("random","random", "in case of balance, randomize input data", true);
   Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account", 0);
   Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
-  Optionpk<double> bstart_opt("bs", "bstart", "start band sequence number",0); 
-  Optionpk<double> bend_opt("be", "bend", "bend band sequence number (set to 0 to include all bands)", 0); 
+  Optionpk<double> bstart_opt("s", "start", "start band sequence number",0); 
+  Optionpk<double> bend_opt("e", "end", "end band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<float> gamma_opt("g", "gamma", "min max boundaries for gamma in kernel function (optional: initial value)",0);
diff --git a/src/apps/pkpolygonize.cc b/src/apps/pkpolygonize.cc
index ef2e85b..99fb6aa 100644
--- a/src/apps/pkpolygonize.cc
+++ b/src/apps/pkpolygonize.cc
@@ -41,7 +41,7 @@ int main(int argc,char **argv) {
   Optionpk<string> mask_opt("m", "mask", "All pixels in the mask band with a value other than zero will be considered suitable for collection as polygons. Use input file as mask to remove background polygon! ");
   Optionpk<double> nodata_opt("nodata", "nodata", "Disgard this nodata value when creating polygons.");
   Optionpk<string> output_opt("o", "output", "Output vector file");
-  Optionpk<string> ogrformat_opt("f", "f", "Output OGR file format","ESRI Shapefile");
+  Optionpk<string> ogrformat_opt("f", "f", "Output OGR file format","SQLite");
   Optionpk<int> band_opt("b", "band", "the band to be used from input file", 0);
   Optionpk<string> fname_opt("n", "name", "the field name of the output layer", "DN");
   Optionpk<short> verbose_opt("v", "verbose", "verbose mode if > 0", 0);
diff --git a/src/apps/pkregann.cc b/src/apps/pkregann.cc
index cd4ebae..96a6d40 100644
--- a/src/apps/pkregann.cc
+++ b/src/apps/pkregann.cc
@@ -35,13 +35,12 @@ int main(int argc, char *argv[])
   Optionpk<string> training_opt("t", "training", "training ASCII file (each row represents one sampling unit. Input features should be provided as columns, followed by output)"); 
   Optionpk<double> from_opt("from", "from", "start from this row in training file (start from 0)",0); 
   Optionpk<double> to_opt("to", "to", "read until this row in training file (start from 0 or set leave 0 as default to read until end of file)", 0); 
-  Optionpk<short> band_opt("b", "band", "band index (starting from 0, either use band option or use start to end)");
   Optionpk<double> offset_opt("\0", "offset", "offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
   Optionpk<unsigned short> cv_opt("cv", "cv", "n-fold cross validation mode",0);
-  Optionpk<unsigned int> nneuron_opt("\0", "nneuron", "number of neurons in hidden layers in neural network (multiple hidden layers are set by defining multiple number of neurons: -n 15 -n 1, default is one hidden layer with 5 neurons)", 5); 
+  Optionpk<unsigned int> nneuron_opt("nn", "nneuron", "number of neurons in hidden layers in neural network (multiple hidden layers are set by defining multiple number of neurons: -n 15 -n 1, default is one hidden layer with 5 neurons)", 5); 
   Optionpk<float> connection_opt("\0", "connection", "connection reate (default: 1.0 for a fully connected network)", 1.0); 
-  Optionpk<float> weights_opt("w", "weights", "weights for neural network. Apply to fully connected network only, starting from first input neuron to last output neuron, including the bias neurons (last neuron in each but last layer)", 0.0); 
+  // Optionpk<float> weights_opt("w", "weights", "weights for neural network. Apply to fully connected network only, starting from first input neuron to last output neuron, including the bias neurons (last neuron in each but last layer)", 0.0); 
   Optionpk<float> learning_opt("l", "learning", "learning rate (default: 0.7)", 0.7); 
   Optionpk<unsigned int> maxit_opt("\0", "maxit", "number of maximum iterations (epoch) (default: 500)", 500); 
   Optionpk<short> verbose_opt("v", "verbose", "set to: 0 (results only), 1 (confusion matrix), 2 (debug)",0);
@@ -55,13 +54,12 @@ int main(int argc, char *argv[])
     training_opt.retrieveOption(argc,argv);
     from_opt.retrieveOption(argc,argv);
     to_opt.retrieveOption(argc,argv);
-    band_opt.retrieveOption(argc,argv);
     offset_opt.retrieveOption(argc,argv);
     scale_opt.retrieveOption(argc,argv);
     cv_opt.retrieveOption(argc,argv);
     nneuron_opt.retrieveOption(argc,argv);
     connection_opt.retrieveOption(argc,argv);
-    weights_opt.retrieveOption(argc,argv);
+    // weights_opt.retrieveOption(argc,argv);
     learning_opt.retrieveOption(argc,argv);
     maxit_opt.retrieveOption(argc,argv);
     verbose_opt.retrieveOption(argc,argv);
diff --git a/src/apps/pkstatascii.cc b/src/apps/pkstatascii.cc
index fe3b842..1c38460 100644
--- a/src/apps/pkstatascii.cc
+++ b/src/apps/pkstatascii.cc
@@ -1,5 +1,5 @@
 /**********************************************************************
-pkstatascii.cc: program to calculate basic statistics from raster image
+pkstatascii.cc: program to calculate basic statistics from text file
 Copyright (C) 2008-2014 Pieter Kempeneers
 
 This file is part of pktools
diff --git a/src/apps/pksvm.cc b/src/apps/pksvm.cc
index d5532f6..60f9ddc 100644
--- a/src/apps/pksvm.cc
+++ b/src/apps/pksvm.cc
@@ -56,11 +56,11 @@ int main(int argc, char *argv[])
   Optionpk<bool> random_opt("random", "random", "Randomize training data for balancing and bagging", true, 2);
   Optionpk<int> minSize_opt("min", "min", "If number of training pixels is less then min, do not take this class into account (0: consider all classes)", 0);
   Optionpk<short> band_opt("b", "band", "Band index (starting from 0, either use band option or use start to end)");
-  Optionpk<double> bstart_opt("bs", "bstart", "Start band sequence number",0); 
-  Optionpk<double> bend_opt("be", "bend", "End band sequence number (set to 0 to include all bands)", 0); 
+  Optionpk<double> bstart_opt("s", "start", "Start band sequence number",0); 
+  Optionpk<double> bend_opt("e", "end", "End band sequence number (set to 0 to include all bands)", 0); 
   Optionpk<double> offset_opt("\0", "offset", "Offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]", 0.0);
   Optionpk<double> scale_opt("\0", "scale", "Scale value for each spectral band input features: refl=(DN[band]-offset[band])/scale[band] (use 0 if scale min and max in each band to -1.0 and 1.0)", 0.0);
-  Optionpk<double> priors_opt("p", "prior", "Prior probabilities for each class (e.g., -p 0.3 -p 0.3 -p 0.2 ). Used for input only (ignored for cross validation)", 0.0); 
+  Optionpk<double> priors_opt("prior", "prior", "Prior probabilities for each class (e.g., -p 0.3 -p 0.3 -p 0.2 ). Used for input only (ignored for cross validation)", 0.0); 
   Optionpk<string> priorimg_opt("pim", "priorimg", "Prior probability image (multi-band img with band for each class","",2); 
   Optionpk<unsigned short> cv_opt("cv", "cv", "N-fold cross validation mode",0);
   Optionpk<std::string> svm_type_opt("svmt", "svmtype", "Type of SVM (C_SVC, nu_SVC,one_class, epsilon_SVR, nu_SVR)","C_SVC");
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
   // Optionpk<bool> weight_opt("wi", "wi", "Set the parameter C of class i to weight*C, for C_SVC",true);
   Optionpk<unsigned short> comb_opt("comb", "comb", "How to combine bootstrap aggregation classifiers (0: sum rule, 1: product rule, 2: max rule). Also used to aggregate classes with rc option.",0); 
   Optionpk<unsigned short> bag_opt("bag", "bag", "Number of bootstrap aggregations", 1);
-  Optionpk<int> bagSize_opt("bs", "bsize", "Percentage of features used from available training features for each bootstrap aggregation (one size for all classes, or a different size for each class respectively", 100);
+  Optionpk<int> bagSize_opt("bagsize", "bagsize", "Percentage of features used from available training features for each bootstrap aggregation (one size for all classes, or a different size for each class respectively", 100);
   Optionpk<string> classBag_opt("cb", "classbag", "Output for each individual bootstrap aggregation");
   Optionpk<string> mask_opt("m", "mask", "Use the first band of the specified file as a validity mask. Nodata values can be set with the option msknodata.");
   Optionpk<short> msknodata_opt("msknodata", "msknodata", "Mask value(s) not to consider for classification (use negative values if only these values should be taken into account). Values will be taken over in classification image.", 0);
@@ -467,7 +467,8 @@ int main(int argc, char *argv[])
       int index=0;
       if(bagSize_opt[iclass]<100)
         random_shuffle(trainingPixels[iclass].begin(),trainingPixels[iclass].end());
-      
+      if(verbose_opt[0]>1)
+	std::cout << "nctraining (class " << iclass << "): " << nctraining << std::endl;
       trainingFeatures[iclass].resize(nctraining);
       for(int isample=0;isample<nctraining;++isample){
         //scale pixel values according to scale and offset!!!
@@ -480,9 +481,13 @@ int main(int argc, char *argv[])
     }
     
     unsigned int nFeatures=trainingFeatures[0][0].size();
+    if(verbose_opt[0]>=1)
+      std::cout << "number of features: " << nFeatures << std::endl;
     unsigned int ntraining=0;
     for(short iclass=0;iclass<nclass;++iclass)
       ntraining+=trainingFeatures[iclass].size();
+    if(verbose_opt[0]>=1)
+      std::cout << "training size over all classes: " << ntraining << std::endl;
 
     prob[ibag].l=ntraining;
     prob[ibag].y = Malloc(double,prob[ibag].l);
@@ -529,7 +534,11 @@ int main(int argc, char *argv[])
     if(verbose_opt[0])
       std::cout << "parameters ok, training" << std::endl;
     svm[ibag]=svm_train(&prob[ibag],&param[ibag]);
+    if(verbose_opt[0]>1)
+      std::cout << "SVM is now trained" << std::endl;
     if(cv_opt[0]>1){
+      if(verbose_opt[0]>1)
+	std::cout << "Cross validating" << std::endl;
       double *target = Malloc(double,prob[ibag].l);
       svm_cross_validation(&prob[ibag],&param[ibag],cv_opt[0],target);
       assert(param[ibag].svm_type != EPSILON_SVR&&param[ibag].svm_type != NU_SVR);//only for regression
@@ -544,8 +553,6 @@ int main(int argc, char *argv[])
       }
       free(target);
     }
-    if(verbose_opt[0]>1)
-      std::cout << "SVM is now trained" << std::endl;
     // *NOTE* Because svm_model contains pointers to svm_problem, you can
     // not free the memory used by svm_problem if you are still using the
     // svm_model produced by svm_train(). 
@@ -607,8 +614,6 @@ int main(int argc, char *argv[])
         if(verbose_opt[0]>=1)
           std::cout << "opening mask image file " << mask_opt[0] << std::endl;
         maskReader.open(mask_opt[0]);
-        assert(maskReader.nrOfCol()==testImage.nrOfCol());
-        assert(maskReader.nrOfRow()==testImage.nrOfRow());
       }
       catch(string error){
         cerr << error << std::endl;
@@ -692,8 +697,6 @@ int main(int argc, char *argv[])
     for(int iline=0;iline<nrow;++iline){
       vector<float> buffer(ncol);
       vector<short> lineMask;
-      if(mask_opt.size())
-        lineMask.resize(maskReader.nrOfCol());
       Vector2d<float> linePrior;
       if(priorimg_opt.size())
 	 linePrior.resize(nclass,ncol);//prior prob for each class
@@ -738,20 +741,6 @@ int main(int argc, char *argv[])
       assert(nband==hpixel[0].size());
       if(verbose_opt[0]>1)
         std::cout << "used bands: " << nband << std::endl;
-      //read mask
-      if(!lineMask.empty()){
-        try{
-          maskReader.readData(lineMask,GDT_Int16,iline);
-        }
-        catch(string theError){
-          cerr << "Error reading " << mask_opt[0] << ": " << theError << std::endl;
-          exit(3);
-        }
-        catch(...){
-          cerr << "error catched" << std::endl;
-          exit(3);
-        }
-      }
       //read prior
       if(priorimg_opt.size()){
         try{
@@ -770,39 +759,70 @@ int main(int argc, char *argv[])
           exit(3);
         }
       }
+      double oldRowMask=-1;//keep track of row mask to optimize number of line readings
       //process per pixel
       for(int icol=0;icol<ncol;++icol){
         assert(hpixel[icol].size()==nband);
         bool masked=false;
-        if(!lineMask.empty()){
-          short theMask=0;
-          for(short ivalue=0;ivalue<msknodata_opt.size();++ivalue){
-            if(msknodata_opt[ivalue]>=0){//values set in msknodata_opt are invalid
-              if(lineMask[icol]==msknodata_opt[ivalue]){
-                theMask=lineMask[icol];
-                masked=true;
-                break;
-              }
-            }
-            else{//only values set in msknodata_opt are valid
-              if(lineMask[icol]!=-msknodata_opt[ivalue]){
-                theMask=lineMask[icol];
-                masked=true;
-              }
-              else{
-                masked=false;
-                break;
-              }
-            }
-          }
-          if(masked){
-            if(classBag_opt.size())
-              for(int ibag=0;ibag<nbag;++ibag)
-                classBag[ibag][icol]=theMask;
-            classOut[icol]=theMask;
-            continue;
-          }
-        }
+        if(mask_opt.size()){
+	  //read mask
+	  double colMask=0;
+	  double rowMask=0;
+	  double geox=0;
+	  double geoy=0;
+
+	  testImage.image2geo(icol,iline,geox,geoy);
+	  maskReader.geo2image(geox,geoy,colMask,rowMask);
+	  colMask=static_cast<int>(colMask);
+	  rowMask=static_cast<int>(rowMask);
+	  if(rowMask>=0&&rowMask<maskReader.nrOfRow()&&colMask>=0&&colMask<maskReader.nrOfCol()){
+	    if(static_cast<int>(rowMask)!=static_cast<int>(oldRowMask)){
+	      assert(rowMask>=0&&rowMask<maskReader.nrOfRow());
+	      try{
+		// maskReader.readData(lineMask[imask],GDT_Int32,static_cast<int>(rowMask));
+		maskReader.readData(lineMask,GDT_Int16,static_cast<int>(rowMask));
+	      }
+	      catch(string errorstring){
+		cerr << errorstring << endl;
+		exit(1);
+	      }
+	      catch(...){
+		cerr << "error catched" << std::endl;
+		exit(3);
+	      }
+	      oldRowMask=rowMask;
+	    }
+	  }
+	  else
+	    continue;//no coverage in this mask
+	  short theMask=0;
+	  for(short ivalue=0;ivalue<msknodata_opt.size();++ivalue){
+	    if(msknodata_opt[ivalue]>=0){//values set in msknodata_opt are invalid
+	      if(lineMask[colMask]==msknodata_opt[ivalue]){
+		theMask=lineMask[colMask];
+		masked=true;
+		break;
+	      }
+	    }
+	    else{//only values set in msknodata_opt are valid
+	      if(lineMask[colMask]!=-msknodata_opt[ivalue]){
+		theMask=lineMask[colMask];
+		masked=true;
+	      }
+	      else{
+		masked=false;
+		break;
+	      }
+	    }
+	  }
+	  if(masked){
+	    if(classBag_opt.size())
+	      for(int ibag=0;ibag<nbag;++ibag)
+		classBag[ibag][icol]=theMask;
+	    classOut[icol]=theMask;
+	    continue;
+	  }
+	}
         bool valid=false;
         for(int iband=0;iband<hpixel[icol].size();++iband){
           if(hpixel[icol][iband]){
diff --git a/src/base/Makefile.am b/src/base/Makefile.am
index d2228de..797920d 100644
--- a/src/base/Makefile.am
+++ b/src/base/Makefile.am
@@ -4,7 +4,7 @@
 
 # the program to build (the names of the final binaries)
 #do not want to install pktestoption
-noinst_PROGRAMS = pktestOption  
+noinst_PROGRAMS = pktestOption
 
 # additional include pathes necessary to compile the C++ library
 AM_LDFLAGS = $(GDAL_LDFLAGS) @AM_LDFLAGS@
@@ -16,7 +16,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/src $(GDAL_CFLAGS) @AM_CXXFLAGS@
 ###############################################################################
 
 #noinst_LIBRARIES = libbase.a
-lib_LTLIBRARIES = libbase.la
+#lib_LTLIBRARIES = libbase.la
 
 # where to install the headers on the system
 libbase_ladir = $(includedir)/pktools/base
@@ -24,14 +24,14 @@ libbase_ladir = $(includedir)/pktools/base
 ## Instruct libtool to include ABI version information in the generated shared
 ## library file (.so).  The library ABI version is defined in configure.ac, so
 ## that all version information is kept in one place.
-libbase_la_LDFLAGS = -version-info $(PKTOOLS_SO_VERSION) $(AM_LDFLAGS)
+#libbase_la_LDFLAGS = -version-info $(PKTOOLS_SO_VERSION) $(AM_LDFLAGS)
 
 # the list of header files that belong to the library (to be installed later)
 libbase_la_HEADERS = Vector2d.h IndexValue.h Optionpk.h PosValue.h
 
 # the sources to add to the library and to add to the source distribution
 ###############################################################################
-libbase_la_SOURCES = $(libbase_la_HEADERS)
+#libbase_la_SOURCES = $(libbase_la_HEADERS)
 
 # list of sources for the binaries
 pktestOption_SOURCES = pktestOption.cc
diff --git a/src/base/Makefile.in b/src/base/Makefile.in
index 9be0026..8ec796e 100644
--- a/src/base/Makefile.in
+++ b/src/base/Makefile.in
@@ -19,7 +19,6 @@
 ###############################################################################
 
 
-
 VPATH = @srcdir@
 am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
 am__make_running_with_option = \
@@ -99,50 +98,14 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
-    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
-    *) f=$$p;; \
-  esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
-  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
-  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
-  for p in $$list; do echo "$$p $$p"; done | \
-  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
-  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
-    if (++n[$$2] == $(am__install_max)) \
-      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
-    END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
-  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
-  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__uninstall_files_from_dir = { \
-  test -z "$$files" \
-    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
-    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
-         $(am__cd) "$$dir" && rm -f $$files; }; \
-  }
-am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libbase_ladir)"
-LTLIBRARIES = $(lib_LTLIBRARIES)
-libbase_la_LIBADD =
-am__objects_1 =
-am_libbase_la_OBJECTS = $(am__objects_1)
-libbase_la_OBJECTS = $(am_libbase_la_OBJECTS)
-AM_V_lt = $(am__v_lt_ at AM_V@)
-am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
-am__v_lt_0 = --silent
-am__v_lt_1 = 
-libbase_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(libbase_la_LDFLAGS) $(LDFLAGS) -o $@
 PROGRAMS = $(noinst_PROGRAMS)
 am_pktestOption_OBJECTS = pktestOption.$(OBJEXT)
 pktestOption_OBJECTS = $(am_pktestOption_OBJECTS)
 pktestOption_LDADD = $(LDADD)
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
 am__v_P_0 = false
@@ -177,31 +140,41 @@ AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
 am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
 am__v_CXXLD_0 = @echo "  CXXLD   " $@;
 am__v_CXXLD_1 = 
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
-	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
-	$(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_ at AM_V@)
-am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
-am__v_CC_0 = @echo "  CC      " $@;
-am__v_CC_1 = 
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
-am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
-am__v_CCLD_0 = @echo "  CCLD    " $@;
-am__v_CCLD_1 = 
-SOURCES = $(libbase_la_SOURCES) $(pktestOption_SOURCES)
-DIST_SOURCES = $(libbase_la_SOURCES) $(pktestOption_SOURCES)
+SOURCES = $(pktestOption_SOURCES)
+DIST_SOURCES = $(pktestOption_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(libbase_ladir)"
 HEADERS = $(libbase_la_HEADERS)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
 # Read a list of newline-separated strings from the standard input,
@@ -373,18 +346,19 @@ top_srcdir = @top_srcdir@
 ###############################################################################
 
 #noinst_LIBRARIES = libbase.a
-lib_LTLIBRARIES = libbase.la
+#lib_LTLIBRARIES = libbase.la
 
 # where to install the headers on the system
 libbase_ladir = $(includedir)/pktools/base
-libbase_la_LDFLAGS = -version-info $(PKTOOLS_SO_VERSION) $(AM_LDFLAGS)
+
+#libbase_la_LDFLAGS = -version-info $(PKTOOLS_SO_VERSION) $(AM_LDFLAGS)
 
 # the list of header files that belong to the library (to be installed later)
 libbase_la_HEADERS = Vector2d.h IndexValue.h Optionpk.h PosValue.h
 
 # the sources to add to the library and to add to the source distribution
 ###############################################################################
-libbase_la_SOURCES = $(libbase_la_HEADERS)
+#libbase_la_SOURCES = $(libbase_la_HEADERS)
 
 # list of sources for the binaries
 pktestOption_SOURCES = pktestOption.cc
@@ -423,44 +397,6 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
-	@$(NORMAL_INSTALL)
-	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
-	list2=; for p in $$list; do \
-	  if test -f $$p; then \
-	    list2="$$list2 $$p"; \
-	  else :; fi; \
-	done; \
-	test -z "$$list2" || { \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
-	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
-	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
-	}
-
-uninstall-libLTLIBRARIES:
-	@$(NORMAL_UNINSTALL)
-	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
-	for p in $$list; do \
-	  $(am__strip_dir) \
-	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
-	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
-	done
-
-clean-libLTLIBRARIES:
-	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; \
-	locs=`for p in $$list; do echo $$p; done | \
-	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
-	      sort -u`; \
-	test -z "$$locs" || { \
-	  echo rm -f $${locs}; \
-	  rm -f $${locs}; \
-	}
-
-libbase.la: $(libbase_la_OBJECTS) $(libbase_la_DEPENDENCIES) $(EXTRA_libbase_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(libbase_la_LINK) -rpath $(libdir) $(libbase_la_OBJECTS) $(libbase_la_LIBADD) $(LIBS)
-
 clean-noinstPROGRAMS:
 	@list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
 	echo " rm -f" $$list; \
@@ -614,9 +550,9 @@ distdir: $(DISTFILES)
 	done
 check-am: all-am
 check: check-am
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
+all-am: Makefile $(PROGRAMS) $(HEADERS)
 installdirs:
-	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libbase_ladir)"; do \
+	for dir in "$(DESTDIR)$(libbase_ladir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: install-am
@@ -651,8 +587,8 @@ maintainer-clean-generic:
 	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
-	clean-noinstPROGRAMS mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+	mostlyclean-am
 
 distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
@@ -678,7 +614,7 @@ install-dvi: install-dvi-am
 
 install-dvi-am:
 
-install-exec-am: install-libLTLIBRARIES
+install-exec-am:
 
 install-html: install-html-am
 
@@ -718,24 +654,23 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am: uninstall-libLTLIBRARIES uninstall-libbase_laHEADERS
+uninstall-am: uninstall-libbase_laHEADERS
 
 .MAKE: install-am install-strip
 
 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \
-	cscopelist-am ctags ctags-am distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-libLTLIBRARIES \
-	install-libbase_laHEADERS install-man install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
+	clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
+	ctags-am distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-libbase_laHEADERS install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
 	uninstall-libbase_laHEADERS
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git



More information about the Pkg-grass-devel mailing list