Opened 10 years ago
Last modified 10 years ago
#5467 closed defect
ENVI driver .hdr corruption — at Version 1
Reported by: | wilsonwaters | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.1 |
Component: | GDAL_Raster | Version: | 1.11.0 |
Severity: | major | Keywords: | envi, hdr |
Cc: | antonio |
Description (last modified by )
We found our ENVI .hdr files were being corrupted whenever opened in write mode with GDAL. No changes to the data or metadata are required to corrupt the file, simply opening the file in write mode was enough. I've attached example before and after .hdr files. These files have map info projection set to "Arbitrary" (we're not storing map data. It's long skinny images of underground drill core).
This is the process causing the corruption in ENVIDataset:
- open envi file in read/write mode uses OPEN_EXISTING flag on .hdr
- ENVIDataset::Open() doesn't understand "Arbitrary" projection so generates a "LOCAL_CS" projection string
- close dataset causing ENVIDataset::FlushCache() to be called
- FlushCache() re-writes hdr file as the bHeaderDirty was set in the Open() function. map info field is omitted for some reason?
- FlushCache() overwrites the old hdr file without clearing first causing trailing data in the file
As far as I can tell there are four bugs in the ENVIDataset related to this:
- ENVIDataset::ProcessMapinfo() Doesn't understand the "Arbitrary" projection and defaults to LOCAL_CS - which is probably ok, but;
- ENVIDataset::WriteProjectionInfo fails to write map info field when projection is LOCAL_CS
- ENVIDataset::Open() causes bHeaderDirty to be set (should only happen when something external updates the image?)
- ENVIDataset::FlushCache() should truncate existing file before overwriting
We're using GDAL 1.11 on windows, though I think the behaviour would be the same on any OS.
The attached patch fixes the issues for me, though my experience of GDAL is limited so I would suggest it would need to be reviewed before being used.
Change History (4)
by , 10 years ago
Attachment: | envidataset.cpp.diff added |
---|
comment:1 by , 10 years ago
Component: | JavaBindings → GDAL_Raster |
---|---|
Description: | modified (diff) |
Owner: | changed from | to
patch for envidataset.cpp