Oft-crop.bash

From Open Foris Wiki

Jump to: navigation, search

oft-crop.bash crops a raster image to the extent of a certain pixel value

Usage: oft-crop.bash <input-img> <output-img> [ { value / -all } ] [ nodata-value ]

Options:
[ { value / -all } ]
   [value] = is the value of the inputfile it should be cropped to
   -all = if image should be cropped to every unique pixel value; output will be named accordingly
[nodata-value]: for this value no cropping will be done; if not provided, it is assumed to be 0 (only applicable for option -all)
  • Oft-crop.bash crops a raster image to the extent of a certain pixel value. This can be useful when, for example, one wants to produce a separate raster image for every district of a country.
  • Input image is a raster image with unique pixel values for each region of interest.
  • In the output image, the value for the region of interest is kept. All other pixels are set to 0.
  • The user can choose to either
    • do the cropping for one single pixel value
    • do the cropping for all occurring pixel values besides the nodata-value. The nodata-value can be specified with the [nodata]-option. If not specified, it is assumed to be 0. In this case, output files will carry the value they have been cropped to in their name.

Exercise:

1. You will need for this exercise the file landuse.shp, digitized manually with QGIS

2. Create a raster file that has the landuse class attribute of the landuse.shp file

gdal_rasterize -a newcol -l landuse -tr 30 30 shapefiles/landuse.shp results/landuse.tif

3. Extract one particular class (in that case the zone that has the label 2000)

oft-crop.bash results/landuse.tif results/lu_class.tif 2000



Back to Open Foris Toolkit Main Page

Back to Tools & Exercises



Personal tools