Oft-extr

From Open Foris Wiki

Jump to: navigation, search

Extracts pixel values from an image for points into a text file.

Usage: oft-extr [-nomd] [-mm] [-avg] [-var] [-ws n] [-o outfile] <pointfile> <img-file>

Options:

-nomd = do not print metadata

-mm = extract min and max values

-avg = extract average values

-var = extract variances

-ws n = size (n) of extraction window (odd)

-o outfile = output file name

Please note that the default behaviour is to extract window's center pixel values.

The text file with the points needs to have spaces as field separators and must not contain strings nor a header line. (If you need to change the field separator in your text file or remove columns that contain strings, you could for example edit the file with awk.)

Both, text file with point coordinates and image, need to be in the same projection.

The programm will process all points that fall within the extent of the image. For all points falling outside of the extent, it will skip them and print on screen "Plot ... is outside the image ... ... size ... ...".


Exercise:

  • Get Example data set
  • For this exercise following tools are used: oft-extr
  • Open your working directory using
cd /home/...

1. Let's run oft-extr using the input image landsat_t1.tif with the point text file training.txt. Output: extr.txt with no extra option:

oft-extr -o extr.txt txt/training.txt images/landsat_t1.tif

You will be asked

X-coord. column in input file?: 2
Y-coord. column in input file?: 3
  • Now we take a closer look at our result:
head extr.txt
      1.00  730785.00 -2456134.00      50.00    3441.00      52.00      24.00      24.00      51.00      65.00     128.00      29.00 
      2.00  730785.00 -2455134.00      50.00    3408.00      59.00      27.00      34.00      47.00      82.00     132.00      46.00 
      3.00  730785.00 -2454134.00      50.00    3374.00      57.00      28.00      33.00      50.00      82.00     131.00      44.00 
      4.00  730785.00 -2453134.00      50.00    3341.00      55.00      26.00      29.00      52.00      72.00     129.00      34.00 
      5.00  730785.00 -2452134.00      50.00    3308.00      60.00      28.00      35.00      54.00      87.00     129.00      45.00 
      6.00  730785.00 -2451134.00      50.00    3274.00      47.00      19.00      18.00      37.00      47.00     124.00      20.00 
      7.00  730785.00 -2450134.00      50.00    3241.00      46.00      19.00      17.00      38.00      44.00     123.00      18.00 
      8.00  730785.00 -2449134.00      50.00    3208.00      59.00      28.00      33.00      60.00      84.00     129.00      43.00 
      9.00  730785.00 -2448134.00      50.00    3174.00      66.00      34.00      42.00      57.00      98.00     130.00      56.00 
     10.00  730785.00 -2447134.00      50.00    3141.00      52.00      23.00      21.00      53.00      61.00     127.00      27.00 

  • Explanation of values for each column:
  • Col1: pixel ID
  • Col2: x-coordinates
  • Col3: y-coordinates
  • Col4: pixel col coordinate
  • Col5: pixel row coordinate
  • Col6 - Col7: center pixel value for bands 1-7

2. Exercise using option -mm and -ws:

oft-extr -ws 3 -mm -o extr_mm.txt training.txt landsat_t1.tif
head extr_mm.txt
1.00  730785.00 -2456134.00      50.00    3441.00      52.00      24.00      24.00      51.00      65.00     128.00      29.00      50.00      23.00      24.00      46.00      64.00     128.00      28.00      52.00      24.00      25.00      53.00      70.00     129.00      32.00 
2.00  730785.00 -2455134.00      50.00    3408.00      59.00      27.00      34.00      47.00      82.00     132.00      46.00      56.00      27.00      33.00      46.00      80.00     131.00      44.00      59.00      31.00      39.00      49.00      90.00     132.00      53.00 
3.00  730785.00 -2454134.00      50.00    3374.00      57.00      28.00      33.00      50.00      82.00     131.00      44.00      54.00      27.00      29.00      48.00      77.00     130.00      41.00      58.00      29.00      36.00      52.00      82.00     131.00      44.00 
4.00  730785.00 -2453134.00      50.00    3341.00      55.00      26.00      29.00      52.00      72.00     129.00      34.00      52.00      24.00      27.00      48.00      68.00     128.00      31.00      58.00      27.00      32.00      54.00      80.00     129.00      41.00 
5.00  730785.00 -2452134.00      50.00    3308.00      60.00      28.00      35.00      54.00      87.00     129.00      45.00      56.00      27.00      31.00      51.00      76.00     129.00      36.00      60.00      30.00      37.00      60.00      90.00     129.00      48.00 
6.00  730785.00 -2451134.00      50.00    3274.00      47.00      19.00      18.00      37.00      47.00     124.00      20.00      45.00      19.00      17.00      37.00      45.00     124.00      18.00      49.00      20.00      19.00      38.00      48.00     125.00      21.00 
7.00  730785.00 -2450134.00      50.00    3241.00      46.00      19.00      17.00      38.00      44.00     123.00      18.00      46.00      19.00      17.00      37.00      40.00     123.00      17.00      49.00      20.00      18.00      39.00      46.00     124.00      21.00 

  • Explanation of values for each column:
  • Col1: pixel ID
  • Col2: x-coordinates
  • Col3: y-coordinates
  • Col4: pixel x coordinated
  • Col5: pixel y coordinates
  • Col6 - Col12: min values for bands 1-7
  • Col13 - Col19: max values for bands 1-7
  • Col20 - Col26: center pixel values for bands 1-7

3. Exercise using option -csv and -ws:

oft-extr -ws 3 -csv -o extr_3.txt training.txt landsat_t1.tif

head extr_3.txt
1.000000,730785.000000,-2456134.000000,50.000000,3441.000000,52.000000,24.000000,24.000000,51.000000,65.000000,128.000000,29.000000
2.000000,730785.000000,-2455134.000000,50.000000,3408.000000,59.000000,27.000000,34.000000,47.000000,82.000000,132.000000,46.000000
3.000000,730785.000000,-2454134.000000,50.000000,3374.000000,57.000000,28.000000,33.000000,50.000000,82.000000,131.000000,44.000000
4.000000,730785.000000,-2453134.000000,50.000000,3341.000000,55.000000,26.000000,29.000000,52.000000,72.000000,129.000000,34.000000
5.000000,730785.000000,-2452134.000000,50.000000,3308.000000,60.000000,28.000000,35.000000,54.000000,87.000000,129.000000,45.000000
6.000000,730785.000000,-2451134.000000,50.000000,3274.000000,47.000000,19.000000,18.000000,37.000000,47.000000,124.000000,20.000000



Back to Open Foris Toolkit Main Page

Back to Tools & Exercises



Personal tools