[gdal-dev] IMD files being created by gdalwarp and driver.Create
Even Rouault
even.rouault at spatialys.com
Fri Jul 15 09:07:01 PDT 2016
Le vendredi 15 juillet 2016 15:31:09, Benjamin Deschamps a écrit :
> Hi Even,
>
> The original file is a Landsat-8 image, I can confirm that it has tags set
> in the imd metadata domain with gdalinfo -mdd imd
> LC80040242014245LGN00_B3.TIF but I'm creating a brand new raster, not
> making a copy, so I'm not sure why the metadata is being transferred. The
> following basic example still has the .IMD file created.
>
> import numpy
> from osgeo import gdal
>
> band =
> "C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/LC80040242014245LGN
> 00_B3.TIF" outpath =
> "C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/LC80040242014245LGN
> 00_B3_test.TIF"
>
> ds = gdal.Open(band)
> proj = ds.GetProjection()
> geot = ds.GetGeoTransform()
> dn = ds.ReadAsArray().astype(numpy.float32)
> ds = None
>
> driver = gdal.GetDriverByName("GTiff")
> ds_out = driver.Create(outpath, dn.shape[1], dn.shape[0], 1,
> gdal.GDT_Float32)
> ds_out.GetRasterBand(1).WriteArray(dn)
> ds_out.SetProjection(proj)
> ds_out.SetGeoTransform(geot)
> ds_out.GetRasterBand(1).SetNoDataValue(0)
> ds_out = None
>
> However, if I write to a different directory, or more curiously to a name
> with a different prefix, it does not create the file.
>
> outpath =
> "C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/newname.TIF"
> outpath =
> "C:/Users/deschampsb/Desktop/test/new/LC80040242014245LGN00_B3_test.TIF"
>
> Is it looking up other files in the directory?
>
OK that makes sense now. There is indeed a general metadata reader that
recognizes Landsat _MTL.txt files (among other potential metadata sources). It
is triggered here whereas it is not desirable in Create() case. Could you file
a ticket on https://trac.osgeo.org/gdal/newticket regarding this ? Thanks
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list