[mapserver-users] gdalinfo error on jp2 file

Rahkonen Jukka jukka.rahkonen at mmmtike.fi
Tue Dec 10 12:08:02 PST 2013


Hi,

I believe this is a driver problem. Image seems to be a 4 band image, probably R-G-B ans Near infrared. There are many JPEG2000 drivers available for GDAL and they are not at all the same when it comes to speed and quality.

First I had a try with gdalinfo and Driver: JP2ECW/ERDAS JPEG2000 (SDK 5.0)

Band 1 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #1
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
Band 2 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #2
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
Band 3 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #3
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined
  Description = Band #4
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240

Another driver lists different interpretation of bands
Driver: JP2OpenJPEG/JPEG-2000 driver based on OpenJPEG library
Band 1 Block=1024x1024 Type=Byte, ColorInterp=Red
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
  Overviews: arbitrary
  Mask Flags: PER_DATASET ALPHA
  Overviews of mask band: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
Band 2 Block=1024x1024 Type=Byte, ColorInterp=Green
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
  Overviews: arbitrary
  Mask Flags: PER_DATASET ALPHA
  Overviews of mask band: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
Band 3 Block=1024x1024 Type=Byte, ColorInterp=Blue
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
  Overviews: arbitrary
  Mask Flags: PER_DATASET ALPHA
  Overviews of mask band: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
Band 4 Block=1024x1024 Type=Byte, ColorInterp=Alpha
  Overviews: 3200x3840, 1600x1920, 800x960, 400x480, 200x240
  Overviews: arbitrary

In any case I am sure that you cannot make any usable service by using Driver: JPEG2000/JPEG-2000 part 1 (ISO/IEC 15444-1).  Try to get JP2KAK, JP2ECW or JP2MrSID driver. Perhaps easiest would be to convert JPEG2000 images into GeoTIFFs with tiles and jpeg compression. It may sound silly but it works. You have only 17000 images and there are about 1500 minutes in a day so you will have the job done within a few days with a good laptop. You will need a good GDAL driver for that also. If you were on Windows you could use the builds by gisinternals which comes nowadays with JP2ECW (SDK 5) driver. Or then you can convert JPEG2000 into GeoTIFF with Kakadu demo program kdu_expand which is fast.

I guess that you must select the three bands out of four for Mapserver to render them as RGB with a PROCESSING directive.

-Jukka Rahkonen-
________________________________
Mark Korver wrote


> Hi, This is more a gdal question than Mapserver, but I figured others have bumped into this problem already. My goal is to get this data working in Mapserver

I am trying to work with NAIP 2012 jp2 files downloaded from the tnris.org<http://tnris.org> site.

You can see the announcement here. I am working with the DOQQs that are about 20-30MB in size and number about 17,000.

http://www.tnris.org/node/199

I am running Ubuntu and gdal version 1.9.  The problem is that when I run gdalinfo on one of the jp2 files I get this error.

"ERROR 1: The number of components indicated in the IHDR box (4) mismatch the value specified in the code stream (1)"

Gdalinfo listing

******************

ubuntu at ip-10-147-199-162:/mnt/tx$ gdalinfo naip12_nc-cir_1m_3603_64_4_20120809.jp2

Driver: JPEG2000/JPEG-2000 part 1 (ISO/IEC 15444-1)

Files: naip12_nc-cir_1m_3603_64_4_20120809.jp2

Size is 6400, 7680

Coordinate System is:

PROJCS["NAD83 / UTM zone 13N",

    GEOGCS["NAD83",

        DATUM["North_American_Datum_1983",

            SPHEROID["GRS 1980",6378137,298.2572221010002,

                AUTHORITY["EPSG","7019"]],

            AUTHORITY["EPSG","6269"]],

        PRIMEM["Greenwich",0],

        UNIT["degree",0.0174532925199433],

        AUTHORITY["EPSG","4269"]],

    PROJECTION["Transverse_Mercator"],

    PARAMETER["latitude_of_origin",0],

    PARAMETER["central_meridian",-105],

    PARAMETER["scale_factor",0.9996],

    PARAMETER["false_easting",500000],

    PARAMETER["false_northing",0],

    UNIT["metre",1,

        AUTHORITY["EPSG","9001"]],

    AUTHORITY["EPSG","26913"]]

Origin = (674180.000000000000000,3993050.000000000000000)

Pixel Size = (1.000000000000000,-1.000000000000000)

Corner Coordinates:

Upper Left  (  674180.000, 3993050.000) (103d 3'57.23"W, 36d 3'59.22"N) Lower Left  (  674180.000, 3985370.000) (103d 4' 3.32"W, 35d59'50.09"N) Upper Right (  680580.000, 3993050.000) (102d59'41.53"W, 36d 3'55.02"N) Lower Right (  680580.000, 3985370.000) (102d59'47.84"W, 35d59'45.90"N)

Center      (  677380.000, 3989210.000) (103d 1'52.48"W, 36d 1'52.58"N)

ERROR 1: The number of components indicated in the IHDR box (4) mismatch the value specified in the code stream (1) Band 1 Block=256x256 Type=Byte, ColorInterp=Undefined Band 2 Block=256x256 Type=Byte, ColorInterp=Undefined Band 3 Block=256x256 Type=Byte, ColorInterp=Undefined Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined

**************

Checking to see what jpeg 2000 formats my apt-get install of gdal supports I get.

 ubuntu at ip-10-147-199-162:/mnt/tx$ gdalinfo --formats Supported Formats:

  VRT (rw+v): Virtual Raster

.................

  ERS (rw+v): ERMapper .ers Labelled

  JPEG2000 (rwv): JPEG-2000 part 1 (ISO/IEC 15444-1)

  L1B (rov): NOAA Polar Orbiter Level 1b Data Set

.................

Is this a jpeg 2000 driver problem? Meaning is this a case of mismatch between the jpeg 2000 driver that my gdal is compiled with and the tnris NAIP jp2 file?

 You can download a sample file using this link (19MB).

http://korver-geodata.s3.amazonaws.com/naip/tx/2012/naip12_nc-cir_1m_3603_64_4_20120809.jp2?AWSAccessKeyId=AKIAJVGZCMETHRONYTUQ&Expires=1417454616&Signature=ZKHM2%2fpmLGn%2b%2b4vXXJKZig5tptM%3d

 Any pointers would be much appreciated.

Mark








More information about the mapserver-users mailing list