Oft-nn-training-data.bash

From Open Foris Wiki

Jump to: navigation, search

Script for preparing a training data text file for oft-nn analysis

Usage: oft-nn-training-data.bash <-i image.tif> <-f field_data.txt> <-x col> <-y col> [-m mask.tif] [-d dem] [-l lu]

  • -i = give the landsat image where grey values are to be picked for the field plot locations
  • -f = give the field data text file
  • -x = give the column where x-coordinate resides in the text file
  • -y = give the column where y-coordinate resides in the text file


Options:

  • -m = give a mask with values 0 and 1, where 0 tells that "this location is not to be picked if a field plot falls here"
  • -d = give a digital elevation model file from which the elevations at field plot locations are to be added to the training data
  • -lu = give a land-use, land cover etc image file from which this information is to be added to the training data


  • Picks field data in a text file based on the extent of given image
  • Image may contain 6 or 7 bands
  • Extracts image values based on field data locations
  • If a mask is given, pixels with mask value 0 are dropped
  • At this point the materials must to be in the same projection
  • The text file is preserved as such. Image grey values are added to the end of each row. If lu and/or dem are given, they appear between the original field data and grey values (lu before dem in case of both)
  • NOTE:Checking of the result is obligatory!!!!


Exercise:

  • Get Example data set
  • For this exercise following tools are used: oft-nn-training-data.bash
  • Open your working directory using
cd /home/...
  • The script oft-nn-training-data.bash extracts image values based on field data locations using input image landsat_t1.tif and for the field data we are using training.txt.
oft-nn-training-data.bash -i landsat_t1.tif -f  training.txt -x 2 -y 3
  • Let's take a closer look at our output values_for_nn
head values_for_nn
1 730785 -2456134 1.00 730785.00 -2456134.00 52.00 24.00 24.00 51.00 65.00 128.00 29.00
2 730785 -2455134 2.00 730785.00 -2455134.00 59.00 27.00 34.00 47.00 82.00 132.00 46.00
3 730785 -2454134 3.00 730785.00 -2454134.00 57.00 28.00 33.00 50.00 82.00 131.00 44.00
4 730785 -2453134 4.00 730785.00 -2453134.00 55.00 26.00 29.00 52.00 72.00 129.00 34.00
5 730785 -2452134 5.00 730785.00 -2452134.00 60.00 28.00 35.00 54.00 87.00 129.00 45.00
6 730785 -2451134 6.00 730785.00 -2451134.00 47.00 19.00 18.00 37.00 47.00 124.00 20.00
7 730785 -2450134 7.00 730785.00 -2450134.00 46.00 19.00 17.00 38.00 44.00 123.00 18.00
8 730785 -2449134 8.00 730785.00 -2449134.00 59.00 28.00 33.00 60.00 84.00 129.00 43.00
9 730785 -2448134 9.00 730785.00 -2448134.00 66.00 34.00 42.00 57.00 98.00 130.00 56.00
10 730785 -2447134 10.00 730785.00 -2447134.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 ID
  • Col5: x-coordinates
  • Col6: y-coordinates
  • Col7 - Col13: centre pixel value for bands 1-7



Back to Open Foris Toolkit Main Page

Back to Tools & Exercises



Personal tools