[gdal-dev] Reading a JP2 file - obj_decode() failed

Jonathan Moules jonathan-lists at lightpear.com
Sat Aug 8 10:48:22 PDT 2020


Hi List,
I have a JP2 file I'm trying to process with Rasterio in Python. But I'm 
getting this error:

rasterio.errors.RasterioIOError: Read or write failed. FILENAME.jp2, 
band 1: IReadBlock failed at X offset 40, Y offset 90: opj_decode() failed

That error seems to come from GDAL. I've tried setting the driver to 
both "JPEG2000" and "JP2OpenJPEG" to no avail.

The file opens fine in QGIS, and I tried both gdal2tiles and rgb2pct 
(via the QGIS installation, which is different from the python/rasterio 
install): those both worked fine too, so clearly GDAL can read it when 
standalone.

Any suggestions?

Thanks,
Jonathan

p.s. -  Also tried the JP2ECW driver but couldn't figure out how to link 
it to GDAL. I mention it only because the links to the JP2ECW on 
https://gdal.org/drivers/raster/jp2ecw.html are now invalid. They seem 
to have moved stuff without using redirects. Seems to be here now: 
https://download.hexagongeospatial.com/search?keyword=&lang=en&product_family=29e5f4b2-f943-4710-9b4a-bd1d16525d1e&download_version=a0edddba-0ce6-4cfb-bbe4-95e59d3c87d2

gdalinfo output below:

Driver: JP2ECW/ERDAS JPEG2000 (SDK 5.3)
Files: FILENAME.jp2
Size is 132000, 248000
Coordinate System is:
PROJCS["British National Grid (ORD SURV GB)",
     GEOGCS["OSGB 1936",
         DATUM["OSGB_1936",
             SPHEROID["Airy 1830",6377563.396,299.3249612664951,
                 AUTHORITY["EPSG","7001"]],
             AUTHORITY["EPSG","6277"]],
         PRIMEM["Greenwich",0],
         UNIT["degree",0.0174532925199433],
         AUTHORITY["EPSG","4277"]],
     PROJECTION["Transverse_Mercator"],
     PARAMETER["latitude_of_origin",49],
     PARAMETER["central_meridian",-2],
     PARAMETER["scale_factor",0.9996012717],
     PARAMETER["false_easting",400000],
     PARAMETER["false_northing",-100000],
     UNIT["metre",1,
         AUTHORITY["EPSG","9001"]]]
Origin = (0.000000000000000,1240000.000000000000000)
Pixel Size = (5.000000000000000,-5.000000000000000)
Metadata:
   COLORSPACE=RGB
   COMPRESSION_RATE_TARGET=0
Corner Coordinates:
Upper Left  (       0.000, 1240000.000) (  9d22'13.04"W, 60d50'27.04"N)
Lower Left  (   0.0000000,   0.0000000) (  7d33'23.21"W, 49d45'58.27"N)
Upper Right (  660000.000, 1240000.000) (  2d48'15.07"E, 60d57'26.43"N)
Lower Right (  660000.000,       0.000) (  1d37' 0.77"E, 49d50'35.22"N)
Center      (  330000.000,  620000.000) (  3d 6'26.52"W, 55d28' 7.68"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
   Description = Red
   Overviews: 66000x124000, 33000x62000, 16500x31000, 8250x15500, 
4125x7750, 2062
x3875, 1031x1937, 515x968, 257x484
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
   Description = Green
   Overviews: 66000x124000, 33000x62000, 16500x31000, 8250x15500, 
4125x7750, 2062
x3875, 1031x1937, 515x968, 257x484
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
   Description = Blue
   Overviews: 66000x124000, 33000x62000, 16500x31000, 8250x15500, 
4125x7750, 2062
x3875, 1031x1937, 515x968, 257x484




More information about the gdal-dev mailing list