pkann(1)
pkann(1) πβ¨
okay bestie, pull up a chair, we're doing pkann β a section 1 manual page, she's iconic, she's giving neural-net-classification-realness π
β¨ NAME β¨
pkann β classify raster image using Artificial Neural Network π§ π¦
πΈ SYNOPSIS πΈ
pkann -t training [-i input] [-cv value] [options] [advanced options]
π DESCRIPTION π
so like, pkann implements an artificial neural network (ANN) to solve a supervised classification problem. the implementation is based on the open source C++ library ( fann β¨http://leenissen.dk/fann/wp/β© ) β no cap, that's the whole engine, that's the vibe π
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. it's giving "you get back what you put in" energy, literally π
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 β nope, not even a little bit. you can use the same training sample for classifying different images, provided the number of bands of the images are identical. use the utility pkextract(1) 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. slay β¨
π OPTIONS π
-i filename,--input filenameβ input image πΌοΈ-t filename,--training filenameβ training vector file. a single vector file contains all training features (must be set as:B0,B1,B2,...) for all classes (class numbers identified bylabeloption). use multiple training files for bootstrap aggregation (alternative to the--bagand--bsizeoptions, where a random subset is taken from a single training file) π§Ί-tln layer,--tln layerβ training layer name(s)-label attribute,--label attributeβ identifier for class label in training vector file. (default:label) π·οΈ-prior value,--prior valueβ prior probabilities for each class (e.g.,-prior 0.3 -prior 0.3 -prior 0.2)-cv value,--cv valueβ n-fold cross validation mode (default:0) π-nn number,--nneuron numberβ number of neurons in hidden layers in neural network (multiple hidden layers are set by defining multiple number of neurons:-nn 15 -nn 1, default is one hidden layer with 5 neurons) π§-m filename,--mask filenameβ only classify within specified mask (vector or raster). for raster mask, set nodata values with the option--msknodata. π-msknodata value,--msknodata valueβ mask value(s) not to consider for classification. values will be taken over in classification image. default is0.-nodata value,--nodata valueβ nodata value to put where image is masked as nodata (default:0)-o filename,--output filenameβ output classification image π€-ot type,--otype typeβ data type for output image ({Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFloat64}). empty string: inherit type from input image-of GDALformat,--oformat GDALformatβ output image format (see alsogdal_translate(1)). empty string: inherit from input image-f OGRformat,--f OGRformatβ output ogr format for active training sample (default:SQLite)-ct filename,--ct filenameβ colour table in ASCII format having 5 columns:id R G B ALFA(0: transparent,255: solid) π-co NAME=VALUE,--co NAME=VALUEβ creation option for output file. multiple options can be specified.-c name,--class nameβ list of class names.-r value,--reclass valueβ list of class values (use same order as in--classoption).-v 0|1|2,--verbose 0|1|2β set to:0(results only),1(confusion matrix),2(debug) π
π¦ Advanced options π¦
-bal size,--balance sizeβ balance the input data to this number of samples for each class (default:0) βοΈ-min number,--min numberβ if number of training pixels is less then min, do not take this class into account (0: consider all classes)-b band,--band bandβ band index (starting from0, either use--bandoption or use--startto--end)-sband band,--startband bandβ start band sequence number (default:0)-eband band,--endband bandβ end band sequence number-offset value,--offset valueβ offset value for each spectral band input features:refl[band]=(DN[band]-offset[band])/scale[band]-scale value,--scale valueβ scale value for each spectral band input features:refl=(DN[band]-offset[band])/scale[band]-a 1|2,--aggreg 1|2β how to combine aggregated classifiers, see also--rcoption (1: sum rule,2: max rule).--connection 0|1β connection rate (default:1.0for a fully connected network) π-w weights,--weights 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) ποΈ-l rate,--learning rateβ learning rate (default:0.7) π--maxit numberβ number of maximum iterations (epoch) (default:500) β³-comb rule,--comb ruleβ how to combine bootstrap aggregation classifiers (0: sum rule,1: product rule,2: max rule). also used to aggregate classes with--rcoption. default is sum rule (0)-bag value,--bag valueβ number of bootstrap aggregations (default is no bagging:1) π-bs value,--bsize valueβ 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. default:100)-cb filename,--classbag filenameβ output for each individual bootstrap aggregation (default is blank)--prob filenameβ probability image. default is no probability image π²-na number,--na numberβ number of active training points (default:1)
π EXAMPLE π
classify input image input.tif with an Artificial Neural Network using one hidden layer with 5 neurons. 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).
pkann -i input.tif -t training.sqlite -o output.tif --nneuron 5 -cv 2
same example as above, but use two hidden layers with 15 and 5 neurons respectively.
pkann -i input.tif -t training.sqlite -o output.tif --nneuron 15 --neuron 5 -cv 2
π₯ SEE ALSO π₯
pkextract(1)
ok that's the whole page bestie, no skips, no summaries, every flag accounted for π―
and that's a wrap on the pkann(1) page, sourced from pkann itself and dated 01 January 2025 β go forth and classify, you absolute icon π«Άππ
π¦ where this page comes from
- ubuntu questing: pktools 2.6.7.6+ds-6build4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms