Quantum GIS access to OTB applications
From OTBWiki
This is a guide to installing and running the OrfeoToolbox modules from within QGis
The OrfeoToolbox applications are available in Qgis via a Python plugin, built on top of the "QGis Processing Framework".
More extensive information on the "QGis Processing Framework" plugin can be found here.
This plugin can also provide an interface to the SAGA modules inside Qgis.
Contents |
Notes for Windows users
On windows platform, the necessary binaries (for both Qgis and OTB) are available within the OSGeo4W distribution : http://trac.osgeo.org/osgeo4w/
As such, the installation procedure is simple to get the OTB functionnalities within Qgis :
- Via the standard "Setup" installer, install the packages called "otb-python" and "osgearth", and "qgis" or "qgis-dev"
- Start Qgis
- Make sure your HTTP proxy settings are defined within the Preferences>Options>Network, if you need them to access the web.
- Start the Python plugin installer
- Make sure the Faunalia repository (http://www.faunalia.it/qgis/plugins.xml) is in your repository list, or add it
- In the "Options" tab, choose to show all extensions, even the experimental ones.
- Install the "Processing Framework Manager" plugin
- Install the "Orfeo Toolbox Module Interface" plugin. You can type "orfeo" in the search tab to quickly get access to the entry
- Hit the Processing>Panel menu entry to make the module list appear
- You can run each module by double-clicking on their name.
Notes for Debian/Ubuntu users
Due to an issue (bugs.debian.org/558733) in the GDAL package, a symbol clash happens when using OTB within QGis.
A workaround to the issue has been provided in GDAL sources, but is not available in the 1.8.1 release.
The recommended procedure is to build a recent version of GDAL sources, and then build both OTB and QGis against this same GDAL version.
Installing GDAL
Set up where the source and installation are
export GDAL_SRC=</path/to/gdal/checkout> export GDAL_INSTALL=</path/to/gdal/installation/directory>
Create the parent dir for source checkout
mkdir -p $GDAL_SRC/..
Create the installation dir
mkdir -p $GDAL_INSTALL
Checkout GDAL sources
svn checkout https://svn.osgeo.org/gdal/trunk/gdal $GDAL_SRC
Change directoy
cd $GDAL_SRC
Configure
./configure --prefix=$GDAL_INSTALL \ --with-libtiff=internal \ --with-geotiff=internal \ --with-rename-internal-libtiff-symbols=yes \ --with-rename-internal-libgeotiff-symbols=yes
Build and install
make make install
Installing QGis
For now on, we need to make sure this GDAL build will be selected by the QGis and OTB configuration process:
export PATH=$GDAL_INSTALL/bin:$PATH export LD_LIBRARY_PATH=$GDAL_INSTALL/lib:$LD_LIBRARY_PATH
Set up directories for building QGis
export QGIS_SRC=</path/to/qgis/checkout> export QGIS_BUILD=</path/to/qgis/build/directory> export QGIS_INSTALL=</path/to/qgis/installation/directory>
mkdir -p $QGIS_BUILD mkdir -p $QGIS_INSTALL
Configure
cd $QGIS_BUILD
cmake $QGIS_SRC \
-DCMAKE_INSTALL_PREFIX:STRING=$QGIS_INSTALL \
-DCMAKE_BUILD_TYPE:STRING=Debug
Build and install
make -j3 make install
Installing OTB
The OTB applications are not part of the latest release, so it is necessary to build recent sources of OTB.
The installation procedure is described in the OTB Software Guide, in the Building from sources section and in the FAQ.
Install necessary software to build OTB
sudo aptitude install mercurial cmake libc6-dev libgcc1 libstdc++6 libtiff4-dev libgeotiff-dev \ libpng12-dev libx11-dev libgl1-mesa-dev libgl1-mesa-dri libglu1-mesa-dev \ libgdal1-dev proj uuid-dev libfltk1.1-dev fluid libexpat1-dev \ libcurl4-gnutls-dev automake autoconf libtool libopenthreads-dev \ libboost-graph-dev libmapnik-dev swig
The gcc version available on Ubuntu Lucid has a bug. It can be worked around by installing gcc 4.5 from this ppa, as follows :
sudo apt-add-repository ppa:ubuntu-toolchain-r/test sudo aptitude update sudo aptitude install g++-4.5 gcc-4.5
Configure the source, build and install directory
Be sure to also have the GDAL_* variable defined as above, and that your previous GDAL build is in your path
export OTB_SRC=</path/to/OTB/checkout> export OTB_BUILD=</path/to/OTB/build/directory> export OTB_INSTALL=</path/to/OTB/installation/directory>
Be sure the directories exists
mkdir -p $OTB_SRC mkdir -p $OTB_BUILD
The sources can be obtained using the Mercurial source control software :
hg clone http://hg.orfeo-toolbox.org/OTB $OTB_SRC
Configure
cmake \ -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-4.5 -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-4.5 -DCMAKE_INSTALL_PREFIX:PATH=$OTB_INSTALL \ -DGDAL_INCLUDE_DIR:PATH=$GDAL_INSTALL/include \ -DBUILD_APPLICATIONS:BOOL=ON \ -DWRAP_PYTHON:BOOL=ON \ -DBUILD_TESTING:BOOL=OFF \ -DBUILD_EXAMPLES:BOOL=OFF \ -DOTB_USE_VISU_GUI:BOOL=OFF \ -DOTB_USE_CURL:BOOL=ON \ -DOTB_USE_PQXX:BOOL=OFF \ -DOTB_USE_PATENTED:BOOL=OFF \ -DOTB_USE_EXTERNAL_BOOST:BOOL=ON \ -DOTB_USE_EXTERNAL_EXPAT:BOOL=ON \ -DOTB_USE_EXTERNAL_FLTK:BOOL=ON \ -DOTB_USE_MAPNIK:BOOL=OFF \ $OTB_SRC
make
make install
Installing the plugins
- Set up the necessary environment before starting Qgis
export PATH=$GDAL_INSTALL/bin:$QGIS_INSTALL/bin:$PATH export LD_LIBRARY_PATH=$GDAL_INSTALL/lib:$QGIS_INSTALL/lib:$OTB_INSTALL/lib/otb export PYTHONPATH=$OTB_INSTALL/lib/otb/python:$PYTHONPATH export ITK_AUTOLOAD_PATH=$OTB_INSTALL/lib/otb/applications
- Check that everything is configured properly
python -c "import otbApplication;print otbApplication.Registry.GetAvailableApplications()"
This should return a list of module names
- Start qgis :
$QGIS_INSTALL/bin/qgis
- Start the Python plugin installer
- Make sure the Faunalia repository (http://www.faunalia.it/qgis/plugins.xml) is in your repository list, or add it
- In the "Options" tab, choose to show all extensions, even the experimental ones.
- Install the "Processing Framework Manager" plugin
- Install the "Orfeo Toolbox Module Interface" plugin (TODO : it would be cool to search otb in the extensions and get this plugin (for now need to search for orfeo))
- At that point you may need to restart Qgis
- Hit the Processing>Panel menu entry to make the module list appear
- You can run each module by double-clicking on their name.
