Getting OTB and Monteverdi

Orfeo Toolbox (OTB) is a robust collection of utility for remote sensing. Initiated and funded by CNES (French space agency) in the frame of a program named ORFEO, OTB is largely maintained by the open source community since 2006. It’s originally a c++ library and can be used from inside Java and Python. The library become more and more popular for it’s multi-threaded and streaming capabilities. No only that, developers introduced an easier and more generic GUI front-end called Montevardi.

Until today (September 9, 2015) OTB is still unavailable for Lubuntu 15.04, so I brought back my old pal Windows XP inside Vbox. Just like GDAL, use OSGEO4W to install OTB. Use the ‘advanced install’ mode to start. Leave the other settings default until you reach ‘select package’ window. You will find OTB under ‘Libs’ category, you can choose to install a binary/ package by clicking ‘skip’ beside it. The installer will download all the dependencies along with the library just like Lubuntu does.  I only choose ‘otb-python’ and got OTB, GDAL and Python with many other dependencies together. You can get Monteverdi (otb-monteverdi2) from ‘Desktop’ category.

Making use of Orfeo Toolbox

OTB has most of the essential remote sensing tool in one place. OSGEO4W Shell shows you the list of utilities, two set for each tool – command line (otbcli) and GUI (otbgui). For example check out the BandMath tool in each section.

C:\>otbcli_BandMath
ERROR: Waiting for at least one parameter...
This is the BandMath application, version 5.0.0
Perform a mathematical operation on monoband images

Complete documentation: http://www.orfeo-toolbox.org/Applications/BandMath.html

Parameters:
        -progress <boolean>        Report progress
MISSING -il       <string list>    Input image list  (mandatory)
MISSING -out      <string> [pixel] Output Image  [pixel=uint8/uint16/int16/uint32/int32/float/double] (default value is float) (mandatory)
        -ram      <int32>          Available RAM (Mb)  (optional, off by default, default value is 128)
MISSING -exp      <string>         Expression  (mandatory)
        -inxml    <string>         Load otb application from xml file  (optional, off by default)

Examples:
otbcli_BandMath -il verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif -out apTvUtBandMathOutput.tif -exp "cos(im1b1)+im2b1*im3b1-im3b2+ndvi(im3b3, im3b4)"

We need to include the MISSING keywords. The GUI version looks like this.

And similar window can be found in Monteverdi, a standalone software with all the tools that OTB has to offer. Not only that, this software can create models, analyze LiDAR data, edit and process raster attribute tables, vector layers and has many other functionalities which are common in many commercial software.

You can use Python and OTB to process multiple rasters at once.

import os
import glob

def concatLandsat(dir):
  band = 3 # The number of desired bands goes here
  inputTif = sorted(glob.glob(os.path.join(dir, "*.TIF")))[:band]
  # Here I had to separate each string with white-space and put double quote around each
  inputImages = ' '.join('"' + x + '"' for x in inputTif)
  # Took the first image name (LT51370432006355BKT00_B1.TIF) so that I know it later
  outputImages = os.path.join(dir, inputTif[0])[:-7] + "_concat.tif"

  os.system('otbcli_ConcatenateImages -il %s -out "%s"' % (inputImages, outputImages))
  return

folderName = r"C:\Documents and Settings\Landsat_image"
concatLandsat(folderName)

Check out the these two set of code to apply Radiometric Indices on an image with RadiometricIndices.

otbcli_RadiometricIndices -in qb_RoadExtract.tif -list Vegetation:NDVI Vegetation:RVI Vegetation:IPVI -out RadiometricIndicesImage.tif

In Python

>>>import otbApplication 
>>>RadiometricIndices = otbApplication.Registry.CreateApplication("RadiometricIndices") 
>>>RadiometricIndices.SetParameterString("in", "qb_RoadExtract.tif", "list", "Vegetation:NDVI", "Vegetation:RVI", "out", "RadiometricIndicesImage.tif") 
>>>RadiometricIndices.ExecuteAndWriteOutput()

Check out the Orfeo Toolbox Cookbook for more examples. Also check out the official tutorials and the documentation.

Pages: 1 2