3

I previously asked about some problems I was having converting JP2/MrSid data to GeoTIFF for use in GeoServer. It was suggested that I needed to add overview data to the 4 GB-sized GeoTIFF -- and that helped. GeoServer then rendered and served the raster and was quite fast about it.

I've since been reading about cloud-optimized GeoTIFFs, and tried to follow the three-step process recommended here:

gdal_translate sample.jp2 sample_deflate.tif -co tiled=yes -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=DEFLATE -co PREDICTOR=2   

cp sample_deflate.tif sample_addo.tif

gdaladdo -r average sample_addo.tif 2 4 8 16 32 64 128 --config PHOTOMETRIC_OVERVIEW YCBCR --config COMPRESS_OVERVIEW JPEG --config JPEG_QUALITY_OVERVIEW 85 --config INTERLEAVE_OVERVIEW PIXEL 

gdal_translate sample_addo.tif sample_compressed.tif -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=JPEG -co JPEG_QUALITY=85 -co PHOTOMETRIC=YCBCR -co COPY_SRC_OVERVIEWS=YES --config GDAL_TIFF_OVR_BLOCKSIZE 512

But the resulting file, after JPEG compression with photometric, would not serve at all in GeoServer. The intermediate file -- with just the added overviews -- serves fine in GeoServer, but is 6 GB in size.

Thinking the problem might be the photometric, I backed up and redid the compression with no photometric:

gdal_translate sample_addo.tif sample_compressed.tif -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 -co COMPRESS=JPEG -co JPEG_QUALITY=85 -co COPY_SRC_OVERVIEWS=YES --config GDAL_TIFF_OVR_BLOCKSIZE 512

It still wouldn't work. So something to do with my third step, compressing the image, is rendering it unusable by GeoServer. (It could also, I guess, be a problem with my GeoServer settings.)

Here is the gdalinfo for the third (not working) file (with photometric compression):

Driver: GTiff/GeoTIFF
Files: sample_compressed.tif
Size is 43221, 36021
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (95.998541666740138,45.001424215510333)
Pixel Size = (0.000138888892252,-0.000138888892252)
Metadata:
  AREA_OR_POINT=Point
Image Structure Metadata:
  COMPRESSION=YCbCr JPEG
  INTERLEAVE=PIXEL
  SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left  (  95.9985417,  45.0014242) ( 95d59'54.75"E, 45d 0' 5.13"N)
Lower Left  (  95.9985417,  39.9985074) ( 95d59'54.75"E, 39d59'54.63"N)
Upper Right ( 102.0014585,  45.0014242) (102d 0' 5.25"E, 45d 0' 5.13"N)
Lower Right ( 102.0014585,  39.9985074) (102d 0' 5.25"E, 39d59'54.63"N)
Center      (  99.0000001,  42.4999658) ( 99d 0' 0.00"E, 42d29'59.88"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
  Overviews: 21611x18011, 10806x9006, 5403x4503, 2702x2252, 1351x1126, 676x563, 338x282
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
  Overviews: 21611x18011, 10806x9006, 5403x4503, 2702x2252, 1351x1126, 676x563, 338x282
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
  Overviews: 21611x18011, 10806x9006, 5403x4503, 2702x2252, 1351x1126, 676x563, 338x282

Any ideas what I'm doing wrong or how I can get GeoServer to serve this?

  • I usually tile and compress the image then add the overviews. Worth a try? – Ian Turton Feb 8 at 17:57
0

This is how we normally do it, works fast and fine for us:

https://geoserver.geo-solutions.it/edu/en/raster_data/processing.html

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

0

I figured out the problem was nothing to do with what I was doing to the raster, but with GeoServer having problems with the JPEG compression itself. It's the same problem as addressed in this question:

Problem with rendering jpeg compressed image - Caused by: java.lang.ClassNotFoundException: org.libjpegturbo.turbojpeg.TJException

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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