GetImageProjection return nothing if used with Export/ImportImage
Description
After creating an application using an OTB image from ExportImage
as input, the function GetImageProjection()
returns an empty string.
In the following code, replacing Execute()
by ExecuteAndWriteOutput()
wrotes a tif with the correct projection (gdalinfo and qgis seem good)
If SetParameterStringList
with path to .tif image is used, GetImageProjection
returns the correct projection.
Steps to reproduce
def do_bandmath(image_name):
bandmath = otb.Registry.CreateApplicationWithoutLogger("BandMath")
bandmath.SetParameterStringList("il", [image_name])
bandmath.SetParameterString("exp", "im1b1")
bandmath.SetParameterString("out", "fake_out.tif")
bandmath.Execute()
otb_im = bandmath.ExportImage("out")
return otb_im, bandmath
otb_image2, dep = do_bandmath("InputImage.tif")
bandmath = otb.Registry.CreateApplication("BandMath")
bandmath.ImportImage("il", otb_image2)
bandmath.SetParameterString("exp", "im1b1+1")
bandmath.SetParameterString("out", "out_image.tif")
bandmath.Execute()
proj = bandmath.GetImageProjection("out")
print(proj) # print empty string
# same behaviour with
# proj = bandmath.GetImageProjection("il")
Configuration information
Linux Ubuntu 20.04, OTB 8.0 , compiled using conda (superbuild)
Edited by Benjamin Tardy