<div dir="ltr">Dear Even,<div>thank you for the quick response and explanation.</div><div>Ok, I think the file was the culprit then. I will try tomorrow with a few other from the Pleiades PH1A batch to test.</div><div>In this case, it was what I wanted to do, because I am warping into resulting COG in the later step of the processing pipeline, so I wanted to save the corrected geotransform information in place.</div><div><br></div><div>Best,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 25 Nov 2020 at 20:45, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On mercredi 25 novembre 2020 19:53:38 CET Bucek, Lubomir wrote:<br>
> Dear all,<br>
> I did not want to file the following question as an issue, as I am not sure<br>
> if I am just not missing anything in configuration, so putting it as a<br>
> question here:<br>
> <br>
> I am trying to change the geotransform of a JPEG2000 file and then save<br>
> back the content via Python bindings on Ubuntu 20.04 - gdal 3.2.0 (based on<br>
> osgeo/gdal:ubuntu-full-latest -<br>
> sha256:6a82b53f12945a3ba8ac168a7488d1cf5ecb351020f67c88abc6691275a70b68)<br>
> <br>
> Following code:<br>
> ds = gdal.Open(input_filename, gdal.GA_Update)<br>
> ulx, xres, xskew, uly, yskew, yres = ds.GetGeoTransform()<br>
> ... do something with geotransform<br>
> ds.SetGeoTransform(geotransform_new)<br>
> del ds<br>
> Throws me into this exception "USE_SRC_CODESTREAM=YES specified, but no<br>
> codestream found":<br>
> <a href="https://github.com/OSGeo/gdal/blob/master/gdal/frmts/openjpeg/openjpegdatase" rel="noreferrer" target="_blank">https://github.com/OSGeo/gdal/blob/master/gdal/frmts/openjpeg/openjpegdatase</a><br>
> t.cpp#L3718-L3722<br>
> <br>
> How does this creationOption by default being False according to<br>
> <a href="https://gdal.org/drivers/raster/jp2openjpeg.html#creation-options" rel="noreferrer" target="_blank">https://gdal.org/drivers/raster/jp2openjpeg.html#creation-options</a> come into<br>
> play while opening and saving an already existing file?<br>
<br>
When updating in place a file, USE_SRC_CODESTREAM=YES is set internally at<br>
<a href="https://github.com/OSGeo/gdal/blob/master/gdal/frmts/openjpeg/" rel="noreferrer" target="_blank">https://github.com/OSGeo/gdal/blob/master/gdal/frmts/openjpeg/</a><br>
openjpegdataset.cpp#L1457<br>
to cause the generation of a new file, reusing the code stream, but just <br>
modifying the other JP2 boxes.<br>
I'm not sure why this doesn't work for you. Perhaps something with the <br>
particular image you edit.<br>
<br>
But I doubt this is what you want to do anyway. Updating the geotransform will <br>
just change the transform and not change any pixel value.<br>
So gdal.Warp() is probably more what you want to do indeed.<br>
<br>
Even<br>
<br>
-- <br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font color="#000000"><font face="Verdana, sans-serif"><span style="font-size:13.3333px"><b>Lubomir Bucek</b></span></font><br></font><p class="MsoNormal"><font color="#000000"><span lang="DE-AT" style="font-size:10pt;font-family:Verdana,sans-serif">Geospatial IT Engineer</span><u></u></font></p><p class="MsoNormal"><font color="#000000"><span lang="EN-GB" style="font-size:10pt;font-family:Verdana,sans-serif">EOX IT Services GmbH</span><span lang="EN-GB" style="font-size:10pt;font-family:Verdana,sans-serif"> <br></span><span lang="EN-GB" style="font-size:10pt;font-family:Verdana,sans-serif">1090 Vienna, Thurngasse 8/4, Austria</span><span lang="EN-GB" style="font-size:10pt;font-family:Verdana,sans-serif"> <br></span><span lang="EN-GB" style="font-size:10pt;font-family:Verdana,sans-serif">T +43 (0)</span><span lang="EN-GB" style="font-size:10pt;font-family:Verdana,sans-serif"> 660</span><span lang="EN-GB" style="font-size:10pt;font-family:Verdana,sans-serif"> 369 7514, </span><span lang="DE-AT" style="font-size:10pt;font-family:Verdana,sans-serif"><span lang="EN-GB"><a href="mailto:gerhard.triebnig@eox.at" target="_blank">lubomir.bucek@eox.at</a></span></span></font></p></div></div></div></div>