First Steps

You can install and use OTB via 3 different methods :

  • the standalone packages

  • the docker image

  • building from source

In this page, we describe simple use cases to make your first steps in the OTB world. This chapter covers OTB Core installation (including its required dependencies) and launch of applications. For a more detailed installation process, you can refer to the Installation page after installing the required dependencies

Linux

On this page, we describe a simple use case for OTB that uses only the Core and FeaturesExtraction package.

System dependencies to run the standalone package

OTB 9 has only a command line interface, which is composed of C++ written applications. The toolbox also provides python bindings compiled with Python 3.8. You need to have some dependencies on your system to use OTB in both cases.

Debian / Ubuntu

# Required packages to extract OTB from the archive and recompile the python bindings
apt update && apt install -y --no-install-recommends g++ swig cmake make python3 python3-dev python3-numpy

Simple OTB use case : Compute NDVI with the CLI interface

Download OTB

curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-9.0.0-Linux-Core.tar.gz -o /Path/Download/OTB-Core-9.0.tar.gz
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-9.0.0-Linux-FeaturesExtraction.tar.gz -o /Path/Download/OTB-FeaturesExtraction-9.0.tar.gz
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-9.0.0-Linux-Dependencies.tar.gz -o /Path/Download/OTB-Dependencies-9.0.tar.gz

Installation

# Install otb
cd /Path/Download
tar xvf OTB-Core-9.0.tar.gz --one-top-level="/Path/To/Install/OTB"
tar xvf OTB-Features-9.0.tar.gz --one-top-level="/Path/To/Install/OTB"
tar xvf OTB-Dependencies-9.0.tar.gz --one-top-level="/Path/To/Install/OTB"
source /Path/To/Install/OTB/otbenv.profile

Download an example image

curl https://www.orfeo-toolbox.org/packages/examples/phr_xs.tif -o /Path/You/Want/phr_xs.tif

Compute NDVI using the CLI interface

otbcli_BandMath –il /Path/You/Want/phr_xs.tif –out ndvi.tif –exp (im1b4-im1b1)/ (im1b4+im1b1)

Use Python API to compute NDVI

To use the Python API you have first to recompile the bindings for your version of Python. By default they are compiled for Python 3.8

# Recompile python bindings
cd /Path/To/OTB-9.0
source otbenv.profile
sh recompile-bindings.sh

Then you can launch :

python3
import otbApplication as otb
appbandmath = otb.Registry.CreateApplication("BandMath")
appbandmath.SetParameterInputImage("/Path/You/Want/xt_PHR.tif")
appbandmath.SetParameterString("exp",“(im1b4-im1b1)/ (im1b4+im1b1))
appbandmath.SetParameterOutputImage("/Path/You/Want/ndvi.tif")
appbandmath.ExecuteAndWriteOutput()

Windows

Windows binary packages are available for Windows 10 64bits or higher. In order to run properly, you need to make sure you installed the required system dependencies

Installation of required dependencies

  • You must have “Visual C++ Redistributable for Visual Studio 2019” installed for using this package. It can be downloaded freely from microsoft

Important Note

Monteverdi has been removed in OTB >= 9 version, you can use QGIS which is now the default viewer for OTB

Docker

System dependencies to run the docker image

In order to run the docker image, you only need docker installed on your machine. The docker image is known to work on MacOS (Intel and Silicon), any Linux, and Windows in the WSL Linux Environment

Please follow this tutorial to install docker depending on your OS : https://docs.docker.com/engine/install/

Get the orfeotoolbox docker image

docker pull orfeotoolbox/otb:latest

Get an example image

curl https://www.orfeo-toolbox.org/packages/examples/phr_xs.tif -o /home/user/Data/phr_xs.tif

Apply your first BandMath processing

docker run -it -v /home/user/Data:/Data orfeotoolbox/otb:latest otbcli_BandMath –il /Data/phr_xs.tif –out ndvi.tif –exp (im1b4-im1b1)/ (im1b4+im1b1)
Important Note:

If you are on MacOS, there is a trick to use the docker image due to the ARM architecture, it is described in the README of the official docker hub image page

MacOS

MacOS support will be deprecated in OTB > 8 because the Toolbox cannot be compiled natively on ARM (Apple Silicon) architecture. We recommend using the docker image which works perfectly on both Intel and Apple Silicon architectures