OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.79k stars 2.51k forks source link

Cannot read multiband jp2 (linux) #2367

Closed JaimeGeoPi closed 4 years ago

JaimeGeoPi commented 4 years ago

Hi, Thank you in advance for your work. I am not a developer but I will try to be clear.

My Environment

-- Operative System: Kubuntu 64 bits (Ubuntu 18.04.4 LTS) -- GDAL version 3.0.4.

Expected behaviour and actual behaviour.

I am trying to work with a jp2 image (georreferenced and with 4 bands). It is available here: https://drive.google.com/file/d/1ZxOUZg2-FKjYwa257VFLMpTXRWxEoP0a/view?usp=sharing

--1--Trying to read this file. QGIS and Octave (rasterread) failed. I think they use GDAL to read the image. --2--Using gdal_translate I get : ERROR 1: psImage->comps[0].data == nullptr --3--Using ogrinfo -ro file.jp2 to get information I get : FAILURE: Unable to open datasource `.....jp2' with the following drivers. ----> Among the drivers it cites, JP2OpenJPEG is included.

More comments.

These problems do not exist in windows.

Kind Regards.

jratike80 commented 4 years ago

JPEG2000 can contain also some vector data but I suggest still to make the second test again with gdalinfo.

JaimeGeoPi commented 4 years ago

Thanks a lot jratike80, really!! I have run gdalinfo in the console and it has worked. However, I have tried to convert the image to tif with gdal_translate and I have got: Input file size is 14880, 9960 0ERROR 1: psImage->comps[0].data == nullptr ERROR 1: psImage->comps[0].data == nullptr ERROR 1: psImage->comps[0].data == nullptr... ..... [several times more]

jratike80 commented 4 years ago

I have Windows and QGIS 3.12 opens the image as totally white but it does not throw errors. Gdal_translate of GDAL 3.1.0dev fails


Input file size is 15040, 10120
0ERROR 1: psImage->comps[0].data == nullptr
ERROR 1: psImage->comps[0].data == nullptr
ERROR 1: 0722_5-1_2019.jp2, band 2: IReadBlock failed at X offset 0, Y offset 0: psImage->comps[0].data == nullptr

Kakadu kdu_show opens the image nicely. Image seems to be created with FME and ECW JPEG 2000 SDK v5.4.0

GDAL validate_jp2.py script informs just about two non-critical issues but I guess that it validates only metadata according a certain schema.

python \data\python\validate_jp2.py 0722_5-1_2019.jp2
WARNING[GMLJP2]: -ogc_schemas_location not specified
WARNING[GENERAL]: "jpx " not found in compatibility list of ftyp, but GMLJP2 box present 

Debug from failing gdal_translate

OPENJPEG: info: Start to read j2k main header (0).
OPENJPEG: info: Main header has been correctly decoded.
OPENJPEG: Grayscale color space
GDALJP2Metadata: Got projection from GeoJP2 (geotiff) box (0): PROJCS["ETRS89 / UTM zone 30N",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222100887,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","25830"]]
MDReaderPleiades: Not a Pleiades product
MDReaderPleiades: Not a Pleiades product
GDAL: GDALOpen(0722_5-1_2019.jp2, this=0000021F05A933A0) succeeds as JP2OpenJPEG.
Input file size is 15040, 10120
GDAL: GDALDefaultOverviews::OverviewScan()
MDReaderPleiades: Not a Pleiades product
MDReaderPleiades: Not a Pleiades product
0GDAL: GDAL_CACHEMAX = 813 MB
GDAL: GDALDatasetCopyWholeRaster(): 14336*1024 swaths, bInterleave=1
OPENJPEG: 14 blocks to load (4 threads)
OPENJPEG: info: Start to read j2k main header (0).
OPENJPEG: info: Main header has been correctly decoded.
OPENJPEG: info: Start to read j2k main header (0).
OPENJPEG: info: Main header has been correctly decoded.
ERROR 1: psImage->comps[0].data == nullptr
ERROR 1: psImage->comps[0].data == nullptr
OPENJPEG: info: Start to read j2k main header (0).
OPENJPEG: info: Main header has been correctly decoded.
ERROR 1: psImage->comps[0].data == nullptr
ERROR 1: 0722_5-1_2019.jp2, band 2: IReadBlock failed at X offset 0, Y offset 0: psImage->comps[0].data == nullptr
GDAL: GDALClose(0722_5-1_2019.jp2, this=0000021F05A933A0)
GDAL: In GDALDestroy - unloading GDAL shared library.
rouault commented 4 years ago

I've determined this is a openjp2 issue and created https://github.com/uclouvain/openjpeg/issues/1241 . Closing this ticket