[gdal-dev] IMD files being created by gdalwarp and driver.Create

Benjamin Deschamps bdeschamps.home at gmail.com
Fri Jul 15 06:31:09 PDT 2016


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/LC80040242014245LGN00_B3.TIF"
outpath =
"C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/LC80040242014245LGN00_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?

Thanks,

Benjamin



On Thu, Jul 14, 2016 at 4:28 PM, Even Rouault <even.rouault at spatialys.com>
wrote:

> Benjamin,
>
> >
> > I am seeing .IMD files being created first by driver.Create() with the
> > GTIFF driver, and then also by gdalwarp (doing a simple reprojection),
> with
> > both input and output in GTIFF format.
> >
> > I've never seen these files before... Can I prevent them from being
> > written?
>
> If they are created, it means that the IMD metadata domain is set on your
> GeoTIFF files. Presumably because it is also set in the source images you
> use.
> There's no option to suppress writing the IMD files when the IMD metadata
> domain is set on a GeoTIFF file. So either make sure it is not set, or
> suppress
> the .imd as a postprocessing.
>
> But just doing a plain driver.Create() without setting metadata should not
> result in a .imd file being written.
>
> >
> > I'm using GDAL 2.0.2 with the Python bindings, and GDAL 2.1.0 for the
> > utilities.
>
> Odd setup. I presume you know what you are doing ;-)
>
> Even
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160715/5faf2c03/attachment.html>


More information about the gdal-dev mailing list