Using another geom file in Orthorectification with otbApplication?


I would like to know if somebody knows how to use another .geom file in the Orthorectification application, when called from the python API.
I know how to do this with strings (e.g. ortho.SetParameterString("", "file.tif?&geom=new.geom") but I wonder how I can use SetParameterInputImage instead, and using another .geom file.
Is this possible?


Hello Rémi,

I don’t think this is possible, because geom files are parsed by the ImageFileReader and ImageFileWriter classes, not by the otb::Image class. When using SetParameterInputImage you are manipulating a SWIG wrapper around an otb::Image and therefore there is no way to provide a geom file.

It is possible to transfer the image metadata from an image to another with the Python API (see this section), maybe it is possible to read the geom with a dummy application, and transfer the metadata to the input of orthorectification ?


Hello @Cedric,

In the doc, I see how to get the metadata, but I wonder how I can “assign” it to a OutputImageParameter (or InputImageParameter).
I’ll give some tries.


I’m not sure, ImportImage and ExportImage can be use to import and export images from a dictionary containing a numpy array and metatadata (origin, requested region, proj ref, itk::ImageMetadata). But we don’t want to use numpy arrays here. Maybe the SetupImageInformation can be used (it is not documented …)

I’m trying to write a script to see if it works.

See the following script. The geom is read by the ReadImageInfo application. The metadata are then copied into the output image of a smoothing application, and used as input of Orthorectification. It seems to work, but I only tested with a develop build. This should be tested with 7.2 too.

import otbApplication as otb
from sys import argv

inImageFilename = argv[1]
geomFilename = argv[2]
outImageFilename = argv[3]

# Read the geom file
readInfoWithGeom = otb.Registry.CreateApplication("ReadImageInfo")
readInfoWithGeom.SetParameterString("in", inImageFilename + "?&geom=" + geomFilename)

# Get the image metadata
imd = readInfoWithGeom.GetImageMetaData("in")

# Try to use it in a pipeline
smoothing =  otb.Registry.CreateApplication("Smoothing")

smoothing.IN = inImageFilename

imagePtr = smoothing.GetParameterOutputImage("out")

# GetBufferedRegion is not exposed in the wrapper (?) but the buffered region 
# is required in SetupImageInformation. Set a default region instead
bufferedRegion = otb.itkRegion()


#Print output geom
readInfoOut = otb.Registry.CreateApplication("ReadImageInfo")
readInfoOut.SetParameterInputImage("in", imagePtr)

orthoRectification =  otb.Registry.CreateApplication("OrthoRectification")

orthoRectification.SetParameterInputImage("", imagePtr)
orthoRectification.SetParameterString("io.out", outImageFilename)


Many thanks. This is perfect!