#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 , 8 years ago
comment:4 by , 8 years ago
Component: | PythonBindings → GDAL_Raster |
---|---|
Keywords: | gtiff metadata added |
Milestone: | → 2.0.4 |
Version: | 2.0.2 → 2.0.0 |
Note:
See TracTickets
for help on using tickets.
trunk r34670 "GTiff: avoid reading external metadata file that could be related to the target filename wheusing Create() or CreateCopy() (fixes #6594)"