logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

pksvm - classify raster image using Support Vector Machine

Description

pksvm implements a support vector machine (SVM) to solve a supervised classification problem.  The imple‐
       mentation  is  based  on  the  open source C++ library libSVM (http://www.csie.ntu.edu.tw/~cjlin/libsvm).
       Both raster and vector files are supported as input.  The output will contain the classification  result,
       either  in  raster or vector format, corresponding to the format of the input.  A training sample must be
       provided as an OGR vector dataset that contains the class labels  and  the  features  for  each  training
       point.   The point locations are not considered in the training step.  You can use the same training sam‐
       ple for classifying different images, provided the number of bands of the images are identical.  Use  the
       utility  pkextract  to  create  a suitable training sample, based on a sample of points or polygons.  For
       raster output maps you can attach a color table using the option -ct.

Example

       Classify  input  image input.tif with a support vector machine.  A training sample that is provided as an
       OGR vector dataset.  It contains all features (same dimensionality as input.tif) in  its  fields  (please
       check pkextract(1) on how to obtain such a file from a "clean" vector file containing locations only).  A
       two-fold  cross  validation  (cv)  is performed (output on screen).  The parameters cost and gamma of the
       support vector machine are set to 1000 and 0.1 respectively.  A colourtable (a five column text file: im‐
       age value, RED, GREEN, BLUE, ALPHA) has also been provided.

       pksvm-iinput.tif-ttraining.sqlite-ooutput.tif-cv2-ctcolourtable.txt-cc1000-g0.1

       Classification using bootstrap aggregation.  The training sample is randomly split  in  three  subsamples
       (33% of the original sample each).

       pksvm-iinput.tif-ttraining.sqlite-ooutput.tif-bs33-bag3

       Classification  using  prior probabilities for each class.  The priors are automatically normalized.  The
       order in which the options -p are provide should respect the alphanumeric order of the class names (class
       10 comes before 2...)

       pksvm-iinput.tif-ttraining.sqlite-ooutput.tif-p1-p1-p1-p1-p1-p1-p1-p1-p1-p1-p1-p0.2-p1-p1-p1

                                                 01 January 2025                                        pksvm(1)

Name

       pksvm - classify raster image using Support Vector Machine

Options

-tfilename, --trainingfilename
              Training vector file.  A single vector file contains all training features (must be  set  as:  b0,
              b1,  b2,...)  for  all  classes (class numbers identified by label option).  Use multiple training
              files for bootstrap aggregation (alternative to the --bag and --bagsize options,  where  a  random
              subset is taken from a single training file)

       -ifilename, --inputfilename
              input image

       -ofilename, --outputfilename
              Output classification image

       -cvvalue, --cvvalue
              N-fold cross validation mode (default: 0)

       -tlnlayer, --tlnlayer
              Training layer name(s)

       -cname, --classname
              List of class names.

       -rvalue, --reclassvalue
              List of class values (use same order as in --class option).

       -ofGDALformat, --oformatGDALformat
              Output image format (see also gdal_translate(1)).

       -fformat, --fformat
              Output ogr format for active training sample

       -coNAME=VALUE, --coNAME=VALUE
              Creation option for output file.  Multiple options can be specified.

       -ctfilename, --ctfilename
              Color table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid)

       -labelattribute, --labelattribute
              Identifier for class label in training vector file.  (default: label)

       -priorvalue, --priorvalue
              Prior  probabilities  for  each class (e.g., -prior 0.3 -prior 0.3 -prior 0.2) Used for input only
              (ignored for cross validation)

       -ggamma, --gammagamma
              Gamma in kernel function

       -cccost, --ccostcost
              The parameter C of C_SVC, epsilon_SVR, and nu_SVR

       -mfilename, --maskfilename
              Only classify within specified mask (vector or raster).  For raster mask, set nodata  values  with
              the option --msknodata.

       -msknodatavalue, --msknodatavalue
              Mask value(s) not to consider for classification.  Values will be taken over in classification im‐
              age.

       -nodatavalue, --nodatavalue
              Nodata value to put where image is masked as nodata

       -vlevel, --verboselevel
              Verbose level

       Advanced options

       -bband, --bandband
              Band index (starting from 0, either use --band option or use --startband to --endband)

       -sbandband, --startbandband
              Start band sequence number

       -ebandband, --endbandband
              End band sequence number

       -balsize, --balancesize
              Balance the input data to this number of samples for each class

       -minnumber, --minnumber
              If  number  of  training pixels is less then min, do not take this class into account (0: consider
              all classes)

       -bagvalue, --bagvalue
              Number of bootstrap aggregations (default is no bagging: 1)

       -bagsizevalue, --bagsizevalue
              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

       -combrule, --combrule
              How to combine bootstrap aggregation classifiers (0: sum rule, 1: product rule, 2: max rule).  Al‐
              so used to aggregate classes with rc option.

       -cbfilename, --classbagfilename
              Output for each individual bootstrap aggregation

       -probfilename, --probfilename
              Probability image.

       -offsetvalue, --offsetvalue
              Offset value for each spectral band input features: refl[band]=(DN[band]-offset[band])/scale[band]

       -scalevalue, --scalevalue
              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)

       -svmttype, --svmtypetype
              Type of SVM (C_SVC, nu_SVC,one_class, epsilon_SVR, nu_SVR)

       -kttype, --kerneltypetype
              Type of kernel function (linear,polynomial,radial,sigmoid)

       -kdvalue, --kdvalue
              Degree in kernel function

       -c0value, --coef0value
              Coef0 in kernel function

       -nuvalue, --nuvalue
              The parameter nu of nu-SVC, one-class SVM, and nu-SVR

       -elossvalue, --elossvalue
              The epsilon in loss function of epsilon-SVR

       -cachenumber, --cachenumber
              Cache ⟨http://pktools.nongnu.org/html/classCache.html⟩ memory size in MB (default: 100)

       -etolvalue, --etolvalue
              the tolerance of termination criterion (default: 0.001)

       -shrink, --shrink
              Whether to use the shrinking heuristics

       -nanumber, --nactivenumber
              Number of active training points

Synopsis

pksvm-ttraining [-iinput] [-ooutput] [-cvvalue] [options] [advancedoptions]

See Also