Oft-avg

From Open Foris Wiki

Jump to: navigation, search

Computes zone/segment averages and standard deviations

Usage: oft-avg -i <infile> -o <outfile> -um <maskfile> [-std] [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64}] [-h help]

Description

  • oft-avg computes zone/segment averages and standard deviations.
  • It produces two output files: an output image and a text file.
  • You need to give at least the input image file (-i option), the output image (-o) and the maskfile (-um).
  • In the output image, each pixel gets assigned the average/standard deviation for the zone/segment it belonged to.
  • The output format in the text file is: ID number_pixels avgband1 ...avgbandN.

Optional Parameters:

-std = program computes and prints out also the std's 
(as extra bands in the output image and extra columns in the text file)
-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFloat64} = data type of output image
  • NOTE: for benefit of users that are running scripts using the older version based on order of data files instead of options -i, -o and -um, the program can still be used that way


Exercise:

1. Open your working directory using

cd /home/...

2. Now we run oft-avg with input: images/landsat_t1.tif, output: results/oftavg.tif, mask: images/segments.tif

The output text file will be named as the output image plus ".txt" (in this case oftavg.tif.txt).

oft-avg -i images/landsat_t1.tif -o results/oftavg.tif -um images/segments.tif

3. Print the first 10 lines of the output text file in terminal:

head results/oftavg.tif.txt
 1 135 49.051852 20.081481 18.370370 36.785185 46.674074 126.059259 20.192593 
 2 54 49.351852 20.370370 18.407407 37.500000 46.555556 125.925926 19.870370 
 3 76 48.578947 19.828947 17.710526 36.657895 43.881579 125.907895 18.881579 
 4 194 49.005155 20.077320 18.268041 37.530928 46.000000 125.670103 19.721649 
 5 221 49.090498 20.176471 18.574661 37.542986 47.565611 125.728507 20.339367 
 6 82 48.878049 20.304878 18.695122 37.243902 48.097561 125.597561 20.780488 
 7 53 48.886792 20.056604 18.339623 37.207547 45.698113 125.698113 19.396226 
 8 120 48.991667 20.216667 18.583333 36.908333 47.200000 126.041667 20.283333 
 9 154 48.980519 19.993506 18.389610 32.474026 45.000000 125.987013 20.337662 
 10 150 49.540000 20.220000 18.853333 32.260000 47.233333 125.973333 21.433333

Explanation of values for each column:

  • Col1: ID (value for zone/segment)
  • Col2: Number of pixels
  • Col3 - col9: Average value of band1, band2, ... band7

4. Open the output file results/oftavg.tif in QGIS. Use Identify Features that can be chosen form the top bar and click on the image. The window Identify Results should pop up and with the average value for each band for that zone/segment:

Band1 49

Band2 21

Band3 20

Band4 41

Band5 50

Band6 126

Band7 22

5. If you also choose to output standard deviations, the format of the output files will be as follows:

  • text file:
    • Col1: ID (value for zone/segment)
    • Col2: Number of pixels
    • Col3 - col9: Average value of band1, band2, ... band7
    • Col10 - col16: Standard deviation of band1, band2, ... band7
  • raster image file:
    • band1 - band7: average for band1, band2, ... band7
    • band8 - band14: standard deviation for band1, band2, ... band7



Back to Open Foris Toolkit Main Page

Back to Tools & Exercises



Personal tools