Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#6594 closed defect (fixed)

Unexpected creation of IMD file when using the same file prefix as a source file containing IMD domain metadata

Reported by: bdeschamps Owned by: hobu
Priority: normal Milestone: 2.0.4
Component: GDAL_Raster Version: 2.0.0
Severity: normal Keywords: gtiff metadata
Cc:

Description

In relation to this thread: https://lists.osgeo.org/pipermail/gdal-dev/2016-July/044826.html

The Python bindings (2.0.2) for driver.Create() are copying IMD domain metadata and creating an IMD file, when the files are written to the same directory and with the same prefix as a file containing the metadata. This is unexpected behaviour for Create.

Test code replicated here:

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

Does not create the file when writing to another directory or using a different prefix:

outpath =
"C:/Users/deschampsb/Desktop/test/LC80040242014245LGN00/newname.TIF"
outpath =
"C:/Users/deschampsb/Desktop/test/new/LC80040242014245LGN00_B3_test.TIF"

Change History (4)

comment:1 by Even Rouault, 8 years ago

trunk r34670 "GTiff: avoid reading external metadata file that could be related to the target filename wheusing Create() or CreateCopy() (fixes #6594)"

comment:2 by Even Rouault, 8 years ago

Resolution: fixed
Status: newclosed

In 34671:

GTiff: avoid reading external metadata file that could be related to the target filename wheusing Create() or CreateCopy() (fixes #6594)

comment:3 by Even Rouault, 8 years ago

In 34672:

GTiff: avoid reading external metadata file that could be related to the target filename wheusing Create() or CreateCopy() (fixes #6594)

comment:4 by Even Rouault, 8 years ago

Component: PythonBindingsGDAL_Raster
Keywords: gtiff metadata added
Milestone: 2.0.4
Version: 2.0.22.0.0
Note: See TracTickets for help on using tickets.