<div dir="ltr">Created a ticket here:<div><a href="https://trac.osgeo.org/gdal/ticket/6594#ticket">https://trac.osgeo.org/gdal/ticket/6594#ticket</a><br></div><div><br></div><div>First ticket, so hopefully I followed protocol.</div><div><br></div><div>Thanks for your help.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 15, 2016 at 12:07 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Le vendredi 15 juillet 2016 15:31:09, Benjamin Deschamps a écrit :<br>
> Hi Even,<br>
><br>
> The original file is a Landsat-8 image, I can confirm that it has tags set<br>
> in the imd metadata domain with gdalinfo -mdd imd<br>
> LC80040242014245LGN00_B3.TIF but I'm creating a brand new raster, not<br>
> making a copy, so I'm not sure why the metadata is being transferred. The<br>
> following basic example still has the .IMD file created.<br>
><br>
> import numpy<br>
> from osgeo import gdal<br>
><br>
> band =<br>
> "C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/LC80040242014245LGN<br>
> 00_B3.TIF" outpath =<br>
> "C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/LC80040242014245LGN<br>
> 00_B3_test.TIF"<br>
><br>
> ds = gdal.Open(band)<br>
> proj = ds.GetProjection()<br>
> geot = ds.GetGeoTransform()<br>
> dn = ds.ReadAsArray().astype(numpy.float32)<br>
> ds = None<br>
><br>
> driver = gdal.GetDriverByName("GTiff")<br>
> ds_out = driver.Create(outpath, dn.shape[1], dn.shape[0], 1,<br>
> gdal.GDT_Float32)<br>
> ds_out.GetRasterBand(1).WriteArray(dn)<br>
> ds_out.SetProjection(proj)<br>
> ds_out.SetGeoTransform(geot)<br>
> ds_out.GetRasterBand(1).SetNoDataValue(0)<br>
> ds_out = None<br>
><br>
> However, if I write to a different directory, or more curiously to a name<br>
> with a different prefix, it does not create the file.<br>
><br>
> outpath =<br>
> "C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/newname.TIF"<br>
> outpath =<br>
> "C:/Users/deschampsb/Desktop/test/new/LC80040242014245LGN00_B3_test.TIF"<br>
><br>
> Is it looking up other files in the directory?<br>
><br>
<br>
</div></div>OK that makes sense now. There is indeed a general metadata reader that<br>
recognizes Landsat _MTL.txt files (among other potential metadata sources). It<br>
is triggered here whereas it is not desirable in Create() case. Could you file<br>
a ticket on <a href="https://trac.osgeo.org/gdal/newticket" rel="noreferrer" target="_blank">https://trac.osgeo.org/gdal/newticket</a> regarding this ? Thanks<br>
<div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br></div>