Troubleshooting¶
Migration from pyotb 1.5.4 (oct 2022) to 2.x.y¶
List of breaking changes:
otbObjecthas ben renamedOTBObjectotbObject.get_infos()has been renamedOTBObject.get_info()otbObject.key_output_imagehas been renamedOTBObject.output_image_keyotbObject.key_input_imagehas been renamedOTBObject.input_image_keyotbObject.read_values_at_coords()has been renamedOTBObject.get_values_at_coords()otbObject.xy_to_rowcol()has been renamedOTBObject.get_rowcol_from_xy()App.output_paramhas been replaced withApp.output_image_keyApp.write()argumentfilename_extensionhas been renamedext_fnameApp.save_objects()has been renamedApp.__sync_parameters()- use
pyotb_app['paramname']orpyotb_app.app.GetParameterValue('paramname')instead ofpyotb_app.GetParameterValue('paramname')to access parameterparamnamevalue - use
pyotb_app['paramname']instead ofpyotb_app.paramnameto access parameterparamnamevalue Output.__init__()argumentsappandoutput_parameter_keyhave been renamedpyotb_appandparam_keyOutput.pyotb_apphas been renamedOutput.parent_pyotb_applogicalOperationhas been renamedLogicalOperation
Known limitations with old versions¶
Note
All defects described below have been fixed since OTB 8.1.2 and pyotb 2.0.0
Failure of intermediate writing (otb < 8.1, pyotb < 1.5.4)¶
When chaining applications in-memory, there may be some problems when writing intermediate results, depending on the order the writings are requested. Some examples can be found below:
Example of failures involving slicing¶
For some applications (non-exhaustive know list: OpticalCalibration, DynamicConvert, BandMath), we can face unexpected failures when using channels slicing
import pyotb
inp = pyotb.DynamicConvert('raster.tif')
one_band = inp[:, :, 1]
# this works
one_band.write('one_band.tif')
# this works
one_band.write('one_band.tif')
inp.write('stretched.tif')
# this does not work
inp.write('stretched.tif')
one_band.write('one_band.tif') # Failure here
When writing is triggered right after the application declaration, no problem occurs:
import pyotb
inp = pyotb.DynamicConvert('raster.tif')
inp.write('stretched.tif')
one_band = inp[:, :, 1]
one_band.write('one_band.tif') # no failure
Also, when using only spatial slicing, no issue has been reported:
import pyotb
inp = pyotb.DynamicConvert('raster.tif')
one_band = inp[:100, :100, :]
# this works
inp.write('stretched.tif')
one_band.write('one_band.tif')
Example of failures involving arithmetic operation¶
One can meet errors when using arithmetic operations at the end of a pipeline when DynamicConvert, BandMath or OpticalCalibration is involved:
import pyotb
inp = pyotb.DynamicConvert('raster.tif')
inp_new = pyotb.ManageNoData(inp, mode='changevalue')
absolute = abs(inp)
# this does not work
inp.write('one_band.tif')
inp_new.write('one_band_nodata.tif') # Failure here
absolute.write('absolute.tif') # Failure here
When writing only the final result, i.e. the end of the pipeline (absolute.write('absolute.tif')), there is no problem.