Opened 8 years ago

Last modified 8 years ago

#6516 closed defect

Incorrect orientation of ECW with Y increasing downward — at Version 1

Reported by: Mateusz Łoskot Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords: ecw
Cc:

Description (last modified by Mateusz Łoskot)

TL:TR; ECW driver seems to assume ECW images are always oriented with Y coordinates increasing "Upward".

// ecwdataset.cpp (r33717)
adfGeoTransform[5] = -fabs(psFileInfo->fCellIncrementY);

It applies to both, GDAL 2.0.0 as well as the current trunk (GDAL 2.2.0dev).

I have two adjacent ECW images:

  • 02QD472.ecw - with Y coordinates increasing "Upward" (Y resolution negative)
  • 02QD474.ecw - with Y coordinates increasing "Downward" (Y resolution positive)

Attached screen shows the files info by ECWHeaderEditor from the latest ERDAS APOLLO Essentials Utilities 2014).

The problem is visible when inspecting corner coordinates with gdalinfo (trimmed output for clarity):

  • 02QD472.ecw - correct coordinates reported
    Driver: ECW/ERDAS Compressed Wavelets (SDK 5.2)
    Files: ..\02QD472.ecw
    Origin = (-10000.100000000000364,-191999.899999999994179)
    Pixel Size = (0.200000000000000,-0.200000000000000)
    Corner Coordinates:
    Upper Left  (  -10000.100, -191999.900)
    Lower Left  (  -10000.100, -193499.900)
    Upper Right (   -8000.100, -191999.900)
    Lower Right (   -8000.100, -193499.900)
    Center      (   -9000.100, -192749.900)
    
  • 02QD474.ecw - incorrect coordinates reported
    Driver: ECW/ERDAS Compressed Wavelets (SDK 5.2)
    Files: ..\02QD474.ecw
    Origin = (-10000.100000000000364,-194999.899999999994179)
    Pixel Size = (0.200000000000000,-0.200000000000000)
    Corner Coordinates:
    Upper Left  (  -10000.100, -194999.900)
    Lower Left  (  -10000.100, -196499.900)
    Upper Right (   -8000.100, -194999.900)
    Lower Right (   -8000.100, -196499.900)
    Center      (   -9000.100, -195749.900)
    

Loading the two images with QGIS (screen attached) also shows, they are not adjacent.

In order to fix it, patch is very simple: removed the -fabs call wraping the fCellIncrementY value. Once fixed, gdalinfo reports correct corner coordinates for the "Downward" 02QD474.ecw:

Driver: ECW/ERDAS Compressed Wavelets (SDK 5.2)
Files: ..\02QD474.ecw
Origin = (-10000.100000000000364,-194999.899999999994179)
Pixel Size = (0.200000000000000,0.200000000000000)
Corner Coordinates:
Upper Left  (  -10000.100, -194999.900)
Lower Left  (  -10000.100, -193499.900)
Upper Right (   -8000.100, -194999.900)
Lower Right (   -8000.100, -193499.900)
Center      (   -9000.100, -194249.900)

The two sample ECW images are 20MB each, so I here is the download URL to single 38MB .7z package with both of them: https://onedrive.live.com/redir?resid=54EB175E9AC78CE0!1483&authkey=!AMScTQpD5ytTmpQ&ithint=file%2c7z

Change History (4)

by Mateusz Łoskot, 8 years ago

Attachment: ECWHeaderEditor.png added

ECW files info reported by ECWHeaderEditor

by Mateusz Łoskot, 8 years ago

Incorrect image placement in QGIS (with GDAL).

by Mateusz Łoskot, 8 years ago

Attachment: ecw-orientation-bug.patch added

Simple patch fixing orientation of the two sample ECW images (linked in the ticket)

comment:1 by Mateusz Łoskot, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.