Installation¶
Orfeo Toolbox installation is straightforward:
Download otb package for your OS. You can choose between:
A full package corresponding to your operating system in the package list. Archives are named OTB-<version>-<OS>. For Windows, “full package” is the only archive. You can find detailled explaination at recommended installation section.
Linux users can choose a lighter installation. You can install only Core package, or specifics modules. OTB dependencies can be resolved either with system packages or our dependencies archive (OTB-<version>-Linux-Dependencies in package download list). Commands are detailled at advanced-installation section.
Configure OTB:
source /Path/To/OTB/otbenv.profile
Play with OTB in terminal (Command-line interface), as QGIS module (Use OTB in QGIS and QGIS interface) or in python scripts (Python API).
If you want the latests features, you might be interested to compile from source. Detailled steps at Compiling OTB from source.
OTB 10.x is known to work on:
Operating System |
Minimum compiler required |
Python version |
---|---|---|
Debian 12 and more & Ubuntu 22.04 and more |
GCC 8 |
Python >= 3.10 |
RedHat 8 |
GCC 8 |
Python >= 3.8 |
Windows 10 / 11 |
MSVC 2019 |
Python 3.10 |
If you want to use another version of python you will need to recompile python bindings as explained in “Recompiling Python Bindings”.
If you plan to use OTB on other operating systems that thoses listed, you can either use Docker images or compile OTB from source (see Compiling OTB from source )
Linux¶
One line installation¶
For a ready to use installation, we provide a script that installs and set the environment for you :
bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)"
This script without arguments downloads the latest version of OTB and installs it in your “$HOME/otb-OTB_VERSION”. Then, it initializes the necessary environment variables and paths and downloads the GDAL python bindings corresponding to your Python version.
After the installation, you are ready to use OTB by calling :
source $HOME/otb/otbenv.profile
You can customize the command by adding parameters to the one line installer :
bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -s OTB_VERSION OTB_INSTALL_DIRECTORY
Example I want to download the 9.1.0 version and install it to /home/user/apps/otb :
bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -s "9.1.0" "/home/user/apps/otb"
Manual Installation : One package containing all the modules¶
With OTB 9 the packaging is made by CMake to deliver a unique self extractible tar.gz to users. All you have to do is downloading the OTB-10.0.0-Linux.tar.gz package.
Important note for RedHat / Fedora / Rocky users
If you are using Fedora, Redhat8, please download the package Linux_RedHat which contains GDAL bindings in a different folder than the standard Linux package. It is because the default system Python user site in RedHat, and distributions based on it, is lib/python3.8/site-packages and in ubuntu/debian it is lib/python3/dist-packages
You can download the package from the website and extract it in your file manager, or from command line :
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-10.0.0-Linux.tar.gz -o /Path/To/Downloads/OTB-10.0.0-Linux.tar.gz
tar xf /Path/To/Downloads/OTB-10.0.0-Linux.tar.gz --one-top-level=/Path/To/OTB_install
source /Path/To/OTB_install/otbenv.profile
Advanced Manual Installation : Modular installation¶
We provide a Core package and standalone optional packages to install over the Core for GNU/Linux x86_64. They include all of the OTB applications along with command line launchers. Since OTB 9.0, it is now possible to have a modular installation, you have to choose which package to download depending on your use case.
See the page OTB Modules to pick the ones you need.
Because OTB is a quite big software, the modular installation helps you to have only the needed software instead of all OTB. You need at least the Core and Dependencies modules and you can install only the components that matters to you.
Download¶
In order to run OTB you will need the OTB-Dependencies.tar.gz package to run the Core AND optional packages that you can install afterwards.
Let’s say you want to start using OTB only with the Core applications, and some months later you realize that you need to do more specific operations such as Learning. In that case you will just need to download the OTB-Learning package and its dependencies. You can then use directly the applications packaged in the Learning package alongside the other Core apps.
# Download mandatory packages to run OTB: Core and Dependencies
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-10.0.0-Linux-Core.tar.gz -o OTB-10.0.0-Linux-Core.tar.gz
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-10.0.0-Linux-Dependencies.tar.gz -o OTB-10.0.0-Linux-Dependencies.tar.gz
# Download optional packages, note that Learning needs FeaturesExtraction
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-10.0.0-Linux-FeaturesExtraction.tar.gz -o OTB-10.0.0-Linux-FeaturesExtraction.tar.gz
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-10.0.0-Linux-Learning.tar.gz -o OTB-10.0.0-Linux-Learning.tar.gz
...
Installation¶
These packages are self-extractable tar.gz archives. You may uncompress the files with:
or tar command line tool.Unless specific needs we advice you to extract all packages on the same directory (like OTB-10.0.0). Nevertheless, since OTB-9.1 packages can be installed in different directories except for Core and Dependencies that should be on the same folder.
# Install each tar gz in the same "top level" folder
tar xvf OTB-10.0.0-Linux-Core.tar.gz --one-top-level="/Path/To/Install/OTB"
tar xvf OTB-10.0.0-Linux-FeaturesExtraction.tar.gz --one-top-level="/Path/To/Install/OTB"
# It is necessary to install the dependencies AFTER the other modules
tar xvf OTB-10.0.0-Linux-Dependencies.tar.gz --one-top-level="/Path/To/Install/OTB"
...
source /Path/To/Install/OTB/otbenv.profile
Be careful to install the dependencies AFTER the modules because the paths in the cmake files are made modular only when you install the dependencies : the resulting installation can be moved elsewhere on the disk. See the section “move installation below”
If you choose to install module in different folders the otbenv.profile script can not guess where you installed them, thus you must manually add module folders to the OTB_APPLICATION_PATH
variable.
Installation folder description¶
Once the archive is extracted, the directory structure consists of:
otbenv.profile
: A script to initialize the environment for OTB executablesrecompile_bindings.sh
: A script to recompile the python bindings with your system’s Pythonbin
: A folder containing application launcher (otbcli.sh)lib
: A folder containing all shared libraries and OTB applications.include
: A folder containing all the necessary headers to compile OTB based projects.share
: A folder containing common resources and copyright mentions.
If you want to use the otbcli launchers, you can initialize your
environment with source otbenv.profile
.
Python bindings¶
Our recommendation is to always recompile the python bindings when you install OTB
Since OTB 10.0.0 OTB bindings for Python 3.10 are distributed as a binary package. Please note that using a different Python version may not be compatible with OTB wrappings directly after installation. If the installation completes without issue, information relating to your Python bindings will be provided.
You must have Python NumPy bindings installed in your system. They can be installed locally without admin rights as follows: “pip install –user numpy”. This is to give users the option to select their own existing Python installation rather than the one dibstributed by the OTB package.
By default, bindings for Python 3.10 will be enabled with the otbenv
script.
Recompiling Python bindings¶
If you are using another version of Python 3 than 3.10, but still want to use OTB Python bindings, it is possible to compile the python bindings again with your version of Python. CMake is required (it is available in most package managers or at [https://cmake.org/]). Make sure you installed the necessary dependencies in the First Steps page
At the root of the OTB installation run :
source otbenv.profile
sh recompile_bindings.sh
You should now be able to import otbApplication
through Python !
Create an healthy Python environment for OTB¶
We strongly recommend to use a virtual env to avoid conflicts between OTB and GDAL when you develop python scripts that uses other dependencies like rasterio, scikit…
# Source your OTB environment
. <your installation directory>/otbenv.profile
# Create a virtual env and install some libraries
python -m venv otb_venv
. otb_venv/bin/activate
pip install --upgrade pip
pip install scikit-image scikit-learn geopandas
# Rastero depends on GDAL and need to be compiled on the flight with current OTB's own GDAL
pip install rasterio --no-binary :all:
# Use your libraries within Python
python
> import rasterio
> import otbApplication as otb
Notes:¶
Multiple installation of OTB can exists in same system without one conflicting the other!
Moving your installed OTB¶
With OTB 9 one can move the installation folder, but once it is done, there is a step to do to ensure the paths are correct.
rm /Path/To/Moved/OTB/tools/install_done.txt
source /Path/To/Moved/OTB/otbenv.profile
# At this time a message will be displayed showing that this is a new installation, this is normal
Windows¶
Before extracting the package, make sure that you have been through the First Steps page
Windows binary packages are available for Windows 10 or higher. They can be downloaded from otb download page .
Extract the zip archive and use one of the launchers, they contain all applications and their launchers (both command line and graphical launchers are provided):
otbenv.ps1
: A script to initialize the environment for OTB executablesbin
: A folder containing application launchers (otbcli.ps1) and the DLLs.lib
: A folder containing application DLLs.include
: A folder containing all the necessary headers to compile OTB based projects.tool
: A folder containing useful scripts to test the installation or to uninstall OTB libraries and headers while keeping all the dependencies.
If you want to use the otbcli launcher, you can initialize a command
prompt with otbenv.ps1
.
The package can be used to compile other projects using OTB (binaries, libraries and headers are included).
Python bindings¶
Since OTB 9.0.0, the bindings for Python 3.10 are distributed. Please note that using a different Python version may not be compatible with OTB wrappings. If the installation completes without issue, information relating to your Python bindings will be provided.
You must have Python numpy bindings installed in your system. They can be installed locally without admin rights as follows: “pip install –user numpy”. This is to give users the option to select their own existing Python installation rather than the one dibstributed by the OTB package.
By default, bindings for Python 3.10 will be enabled with the otbenv
script.
Docker image¶
The following docker images are availables on DockerHub. It is the only way to run OTB for MacOS since the Intel architecture is no more in the Mac ecosystem.:
Tag |
OS base |
Python version |
---|---|---|
10.0.0 |
ubuntu 22.04 |
Python 3.10 |
10.0.0_ubuntu24 |
ubuntu 24.04 |
Python 3.12 |
It can be used on any device running Docker with the following instruction:
# you can adapt the version you want using different tag like orfeotoolbox/otb:10.0.0
docker pull orfeotoolbox/otb
To run CLI tools, you can launch the docker image with:
docker run -it orfeotoolbox/otb
If you are planning on using the image on MacOS with an Apple Silicon chip (M1,M2,M3) :
docker run -it --platform=linux/amd64 orfeotoolbox/otb:10.0.0
Nix¶
Nix for OTB¶
Nix provides a unique approach to package management that ensures reproducible, reliable, and conflict-free software environments. For OTB users and developers, Nix offers several advantages:
Pure reproducibility: Exact same OTB environment across different machines and time
Isolated dependencies: No conflicts with system packages or other projects
Declarative configuration: Environment defined in code that can be version controlled
Rollbacks: Easy to switch between different versions of OTB or its dependencies
Multi-user support: Different users can have different OTB configurations without interference
Installing Nix¶
Before installing OTB with Nix, install the Nix package manager if it isn’t already installed:
# Install Nix using the recommended installer
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Alternatively, visit Zero to Nix for detailed installation instructions for your specific operating system.
Installing OTB via Nix¶
The OTB package in Nix is available on both stable and unstable channel.
To install OTB via Nix:
For temporary usage in a development environment:
# Install the latest stable OTB version
nix shell nixpkgs#otb
# Or pass a specific channel such as stable version
nix shell github:NixOS/nixpkgs/nixos-24.11#otb
# Or unstable version (mostly the bleeding edge version)
nix shell github:NixOS/nixpkgs/nixpkgs-unstable#otb
If using NixOS, you can add OTB to system configuration by adding the following to configuration.nix:
environment.systemPackages = with pkgs; [
otb
];
Development Environments¶
Using Python with OTB:
To use OTB with Python, you’ll need to set up the correct environment variables. Here are development environment examples that configure the environment properly:
Using shell.nix:
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-24.11.tar.gz") {
}
}:pkgs.mkShell {
buildInputs = [
pkgs.otb
];
# we add this environment variables for otb to be importable via python
postShellHook = ''
export OTB_APPLICATION_PATH="${pkgs.otb}/lib/otb/applications"
export PYTHONPATH="$PYTHONPATH:${pkgs.otb}/lib/otb/python"
'';
}
Save this to a file named shell.nix and run nix-shell in the same directory to enter an environment with OTB properly configured for Python use.
Using flake.nix (recommended):
{
description = "OTB development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux"; # Change to match your system
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
otb
];
# we add this environment variables for otb to be importable via python
postShellHook = ''
export OTB_APPLICATION_PATH="${pkgs.otb}/lib/otb/applications"
export PYTHONPATH="$PYTHONPATH:${pkgs.otb}/lib/otb/python"
'';
};
};
}
Save this to a file named flake.nix and run nix develop in the same directory to enter the development environment.
Once inside the Nix shell or flake development environment, you can import and use OTB in Python.
Advantages of using Nix flakes:
Reproducibility: Flakes lock all dependencies, ensuring that your environment remains consistent across different machines and over time.
Explicit dependencies: Flakes make dependencies explicit and always use the exact same Nixpkgs version.
Composability: Flakes can be easily composed together, making it simpler to create complex development environments.
Better caching: Outputs are properly cached, leading to faster builds.
Standardized interface: Flakes provide a standardized way to interact with Nix packages and environments.
Simplified sharing: Environments can be easily shared with others, ensuring they get exactly the same setup.
After installation, you can use OTB applications directly from the command line or import the OTB modules in Python.
Notes:¶
When setting up a new project with this flake, you should initialize a Git repository in your project directory using
git init
and add the nix files to be tracked usinggit add *.nix
. This is necessary because Nix flakes require a Git repository to track changes properly.
Complex Development Environments¶
One advantage of Nix is the ability to install OTB with different Nix packages seamlessly. One can find all available packages in the Nix package repository at Nixpkgs Search.
Using flake.nix with Python virtual environment:
{
description = "OTB development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
};
outputs =
{ self, nixpkgs }:
let
system = "x86_64-linux"; # Change to match your system
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python3;
pyPkgs = python.pkgs;
nativePkgs = with pkgs; [
otb
# gqis
# git
# Add other packages as needed
];
extraPyPkgs = with pyPkgs; [
# rasterio
# geopandas
# scikit-learn
# scikit-image
# Add other python packages as needed
];
pyEnv = python.withPackages (ps: with ps; extraPyPkgs);
in
{
devShells.${system}.default = pkgs.mkShell {
# this creates a .venv directory inside the project folder to be consumed by IDE
venvDir = "./.venv";
packages = with pkgs; [
pyPkgs.venvShellHook
nativePkgs
pyEnv
];
postShellHook = ''
export OTB_APPLICATION_PATH="${pkgs.otb}/lib/otb/applications"
export PYTHONPATH="$PYTHONPATH:${pkgs.otb}/lib/otb/python"
'';
};
};
}
This setup creates a development environment that combines OTB with Python packages managed by Nix, while also providing a virtual environment structure that can be useful for IDE integration and organization of additional development tools.
Using direnv and nix-direnv with flakes¶
To make your development environment even more convenient, you can combine flakes with direnv and
nix-direnv. This automates the process of loading your development environment whenever you
enter your project directory, saving you from manually running nix develop
each time.
Setting up direnv with nix-direnv¶
Create a .envrc file in your project directory with the following content:
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
fi
use flake
Allow direnv to run in this directory:
direnv allow
Add this to your shell configuration file (
.bashrc
,.zshrc
, etc.) to hook direnv into your shell:
eval "$(direnv hook bash)" # or zsh, fish, etc.
Now, whenever you enter your project directory, direnv will automatically load your Nix flake
environment defined in flake.nix
. When you exit the directory, it will unload the environment,
keeping your global environment clean.
Benefits of direnv with nix-direnv¶
Automatic environment activation: No need to manually run
nix develop
every time you start workingImproved caching: nix-direnv provides better caching of Nix environments than plain direnv
Project-specific environments: Different projects can have different dependencies without conflicts
Seamless workflow: Your terminal will always have the right tools and environment variables for the current project
This approach works perfectly with the flake.nix file shown earlier, creating a fully reproducible and automatically loaded development environment for OTB with all the necessary paths and dependencies configured.
To use OTB with Python in this environment, you don’t need to do anything special - just enter the
directory and start coding. The environment variables set in the flake’s postShellHook
will
ensure Python can find the OTB modules.
Notes:¶
If you’re using VSCode or other IDEs, you may need additional configuration to make them recognize the direnv-loaded environment. Consider installing the appropriate extensions for your editor to support direnv integration.
Advanced Configuration of OTB with Nix¶
For more advanced usage such as building from source with remote modules, docker build, you may refer to otb-nix.
Distribution packages¶
Warning! These packages may not be up-to-date with latest OTB releases. In addition, some features of the library may not be available on every platform. Some of these are not maintained by the OTB-team. If you want to get involved in the packaging of OTB for your favourite platform, please contact us through the developer’s mailing list: otb-developers@googlegroups.com.
There are OTB packages for Debian since version 5.2.0. OTB Applications packages may be available as Debian packages through APT repositories:
otb-bin for command line applications
python-otb for python applications
apt install otb-bin python-otb
Due to license issues, the OTB package built in Debian doesn’t contain 6S. As a consequence, the package does not contain the OpticalCalibration application.
This is why it is recommended to use the official binary package.