How to install otb in win 10?

I download otb 9.0 win64.zip in your website.
and i set the folder path in qgis3.34
image

it seems the otb in processing is ok
image

while if I want to process some data not in gui, just with python call the for example edgeextraction what should i do?

My system*: *Windows10
Version of the OTB: 9.0?

I find some code in the internet, while I feel I have to no way to add the otb algorithm in python.

for alg in QgsApplication.processingRegistry().algorithms():
print(alg.id(), “->”, alg.displayName())
it could print the algorithm in qgis including gdal native and qgis
just like this
qgis:variabledistancebuffer → Variable distance buffer
qgis:vectorlayerhistogram → Vector layer histogram
qgis:vectorlayerscatterplot → Vector layer scatterplot

the code is just like this
from qgis import processing
from qgis.core import QgsProject, QgsProcessingFeedback

Initialize feedback for processing

feedback = QgsProcessingFeedback()

Define the parameters for the OTB tool

params = {
‘INPUT’: ‘path/to/your/input/image.tif’, # Input image path
‘OUTPUT’: ‘path/to/your/output/image.tif’, # Output image path
# Add other parameters specific to the OTB tool here
}

Specify the OTB algorithm you want to use (e.g., ‘otb:ImageFilter’)

algorithm = 'otb:EdgeExtraction ’

Run the OTB processing algorithm

result = processing.run(algorithm, params, feedback=feedback)

Optionally, add the output layer to the QGIS project

QgsProject.instance().addMapLayer(result[‘OUTPUT’])

READ ME FIRST
The Usage category is meant to discuss about OTB usage. You are welcome to ask questions about OTB installation and compilation, OTB applications, OTB Python environment, OTB-QGIS plugin, and other topic related to the Orfeo Toolbox.

Before posting, please:

  • look for similar issues on this forum. For example, you could search for the error message you get, or the name of the application you are using.
  • If you did not already, consider searching / reading the CookBook.
  • Take the time to say Hi, and be friendly :heart:

In order to receive the help you need, you will have to give us some information and details about the context and what you are trying to achieve. To assist you in the writing of you question, use this template, and replace the texts written in italic with what correspond to your situation.

:arrow_double_up: After reading and understanding this, you may delete that part of the text :arrow_double_up:


Context

Explain briefly what you are trying to do

Configuration setup

My system: Windows10, macOS, Debian 9?
Version of the OTB: 7.1/8.0?
I installed the OTB with: the binaries, the Debian package management, the SuperBuild, other?

If relevant, you may also provide:
QGIS version: 3.10.8, 3.14?
Python version: 3.5, 3.8?

Description of my issue

This is where you give details on what you are trying to achieve, describe the different steps you took, and the results you obtained. Don’t hesitate to share input parameters, logs and error messages, ether with a text file or a screenshot, or directly included using backticks like this:
My error message

I also try the pyotb from github
but it shows
2024-09-25 20:20:59 (INFO) [pyotb] Failed to import OTB. Searching for it…
OTB libraries not found on disk. To install it, open an interactive python shell and ‘import pyotb’

OTB libraries not found on disk. and maybe i need install it
while I download the 9.0_win64.zip in win 10 ? so what should I do?

need some help.

Hi,

You can use the python bindings outside of QGIS with a python terminal.
You can go to your OTB install folder and execute the otbenv.bat. Then you can launch the python interpreter and try “import otbApplication”.

Note : with otb 9.0 there was a problem during the release with python 3.10 so we had to stick with python 3.7 because of a specific package. Now it is fixed in otb 9.1-rc2 which I encourage you to get. You have to use the same python version which OTB uses, so python 3.10. You can download otb 9.1-rc2 here :
https://www.orfeo-toolbox.org/packages/OTB-9.1.0-rc2-win64.zip

Note 2 : If it does not work in a windows terminal, you can try with a bash terminal (typically installed with WSL or Git for Windows) and instead of using otbenv.bat you should do “source otbenv.bash” and try executing python

Best regards

thank you for your reply.
image
I really puzzled . I run the otbenv.bat file unzipped from 9.1.0-rc2-win64.zip, maybe the path variable exist blank in, it show ‘At this moment, there should not be any’ files\nvidia in the cmd interface.
I have no way in run this bat file.
I just want to create a conda environment both include qgis and otb to process remote sensing data,
could you tell me how to add the otbprovided function to qgis?

I guess you should try .\otbenv.bat to launch it. Our support for Windows is limited as the team is running on Linux. It is working on Windows with a bash terminal. BTW cmd is getting deprecated, powershell should be more reliable in executing bat script.

I don’t get it, you want to use the python interface in command line right ? Outside of QGIS ?
QGIS is the way to go for OTB with graphical interfaces on windows because you could easily launch a processing.

I use win 10
maybe i should use ubuntu to test your software. powershell show the same
image

I use the miniforge3 , I create conda environment with qgis in it, now I want to add otb in it
I have many data to process, so I want to process data with python in pycharm in batch eg calculate ndvi ndwi, not in gui.

I spend some time in combining this, but failed,

You have the possibility to install WSL on windows, which permits to run Ubuntu within Windows.

I don’t understand why doing .\otbenv.bat shows you somethig about NVIDIA which is nonsense.

The best solution for your use case is to use ubuntu yes, OTB 9 is working flawlessly on ubuntu 20, 22, 24… with python scripts.

We tested a lot otb with conda but found it very unstable that is why we don’t provide support for a conda recipe for otb. but you can install it and use it via the python from your conda env without problem.

just like this, the path environment variable exist blank, so it failed in running otbenv.bat

image

I can use the otb data process in gui, I think if the otb plugin’s function could be add or Registry in the qgis , it maybe ok.
while I do not know how to add them

for alg in QgsApplication.processingRegistry().algorithms():
print(alg.id(), “->”, alg.displayName())

native:zonalhistogram → Zonal histogram
native:zonalstatistics → Zonal statistics (in place)
native:zonalstatisticsfb → Zonal statistics
qgis:advancedpythonfieldcalculator → Advanced Python field calculator
qgis:barplot → Bar plot
qgis:basicstatisticsforfields → Basic statistics for fields

I create a new environment in miniforge , and install the pyotb from github.

Although I didn’t quite understand what pyotb did
there is a red line alert in the import part :crazy_face: , but it did run successfully.

image

image

thanks