I am trying to open a JP2 file in QGIS and it fails.

How do I track down the cause of the issue, be it with my system or with the file itself?

The file is a HiRISE image of Gale Crater on Mars, and is available here: http://hirise-pds.lpl.arizona.edu/download/PDS/RDR/ESP/ORB_032400_032499/ESP_032436_1755/ESP_032436_1755_COLOR.JP2

On my ageing MacBook running QGIS 1.8.0 and GDAL 1.9.2 on Mac OS 10.7.5 the file does open in QGIS, but gdal can't deal with it...

$ gdalinfo ESP_032436_1755_COLOR.JP2
ERROR 4: `ESP_032436_1755_COLOR.JP2' not recognized as a supported file format.

I could use the file using QGIS on that machine, but I'd rather use my new laptop which runs GDAL 1.9.0 and QGIS 2.1.0-Master on Ubuntu 13.04 (I installed the Master version because of difficulties installing QGIS 1.8 on Ubuntu 13.04, perhaps the release of 2.0 will have fixed those issues).

On this machine if I try to open the file in QGIS it freezes for 2-3 minutes, then QGIS crashes and closes with no error messages. gdalinfo works a little...

$ gdalinfo ESP_032436_1755_COLOR.JP2
Driver: JPEG2000/JPEG-2000 part 1 (ISO/IEC 15444-1)
Files: ESP_032436_1755_COLOR.JP2
Size is 9679, 44908
Coordinate System is:
PROJCS["Equirectangular MARS",
Origin = (-2523306.125000000000000,-268608.875000000000000)
Pixel Size = (0.250000000000000,-0.250000000000000)
Corner Coordinates:
Upper Left  (-2523306.125, -268608.875) (137d25'49.08"E,  4d31'53.74"S)
Lower Left  (-2523306.125, -279835.875) (137d25'49.08"E,  4d43'15.60"S)
Upper Right (-2520886.375, -268608.875) (137d28'16.04"E,  4d31'53.74"S)
Lower Right (-2520886.375, -279835.875) (137d28'16.04"E,  4d43'15.60"S)
Center      (-2522096.250, -274222.375) (137d27' 2.56"E,  4d37'34.67"S)

The system freezes for 2-3 minutes between the "Center" line and the "Killed" line. I've also tried using gdal_translate to convert the JP2 to a tif image, but with similar results.


2 Answers 2

$ gdalinfo ESP_032436_1755_COLOR.JP2
ERROR 4: `ESP_032436_1755_COLOR.JP2' not recognized as a supported file format.

For your older QGIS 1.8.0 install, it looks like you do not have a JPEG 2000 GDAL 1.9 driver installed. I could not get the noted .JP2 file to load at all in QGIS 1.8.0 with GDAL 1.9, but you may try by downloading and installing the ECW plugin v1.9.2-1 from Kyngchaos.com, and possibly have better luck.

Once installed, turn off other JPEG 2000 drivers under Options-> GDAL (like JP2OpenJPEG and JPEG2000), so that JP2ECW is the only driver trying to load the .JP2 file. You can also use the environment variable GDAL_SKIP in Terminal, e.g.:


when testing the gdalinfo command. Note that the linked-to page even discusses how the GDAL_SKIP variable helps with the spurious JPEG 2000 drivers issue.

$ gdalinfo ESP_032436_1755_COLOR.JP2
Driver: JPEG2000/JPEG-2000 part 1 (ISO/IEC 15444-1)

In the above attempt, the JPEG2000 driver is being used. I did not have any luck with that driver and your .JP2 file (regardless of GDAL version). However, I did get the file to load (and very quickly) using the Kyngchaos ECW plugin v1.10.1-1 driver:

enter image description here

However, the odd thing here is that I could not do so with the Kyngchaos GDAL binary, only when I used a QGIS compiled from a custom homebrew GDAL and the Kyngchaos ECW plugin v1.10.1-1 driver (statically built) used as a GDAL plugin.

When using just the Kyngchaos GDAL, I got the following error:

dyld: lazy symbol binding failed: Symbol not found: _GDALIsInGlobalDestructor
  Referenced from: /Library/Application Support/GDAL/1.10/PlugIns/gdal_ECW_JP2ECW.dylib
  Expected in: flat namespace

Which was found in the hombrew GDAL, but not Kyngchaos's.

$ nm -g /usr/local/lib/libgdal.dylib | grep 'GDALIsInGlobalDestructor'
0000000000264376 T _GDALIsInGlobalDestructor

So, it looks like maybe a bug in Kyngchaos GDAL binary. I have reported this. Please post whether you have better luck.

UPDATE: So, I completely missed the fact that your new machine was running Ubuntu.

If you are using the UbuntuGIS repository for your QGIS install supporting packages, you can install the following:

libgdal-ecw - 1.10.0-1~raring4

That should install the proprietary ECW GDAL plugin. Not entirely sure if the JP2 support is included.

Meanwhile on Mac, I also had success reading your JP2 file using the JP2OpenJPEG driver, it just took a very long time, which made it fairly unusable in QGIS, since each pan/zoom was painfully slow. If you can't get the JP2ECW driver to open the file, maybe you can use GDAL from the command line to convert the JP2 image to a more useable format using the JP2OpenJPEG driver. Just expect it might take a very long time.

  • 2
    Of note: bug reports, such as this, are probably better reported on the issue tracker for QGIS, as they are a bit too temporal for a StackExchange Q&A. Very clear and well-documented report, regardless.
    – dakcarto
    Commented Oct 9, 2013 at 18:57
  • Thanks, that's a very thorough answer and it confirmed that the fault is probably a bug and not just a poorly configured system. I wasn't able to make use of the Kingchaos plugin because my new laptop isn't a mac (it's Ubuntu). I got done what I needed to get done with the file on my old Mac so the issue isn't a priority for me any more. In the meantime I'll report the bug to the QGIS team and hopefully there'll find the fault, I don't feel confident altering my own gdal build.
    – EddyTheB
    Commented Oct 10, 2013 at 15:41

QGIS 2.0 needs GDAL 1.10 - at least for MacOSX.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.