4

I have a big GeoTIFF that I want to stream through a WMS within GeoServer (v.2.11). The size of the image is about 7GB, consisting on a very large high resolution RGB image. I have allowed enough heap space within JVM in order to display the imagery. However, I would like to compress the image so it can be more responsive when exploring through and so it will allocate less memory. I have followed some of the recommendations here.

My strategy was to compress the GeoTIFF with JPEG compression and use that as a data store in GeoServer. However, this seems not to work. This is the gdal command I have used to translate the image:

gdal_translate -of GTiff -co "BIGTIFF=YES" -co "COMPRESS=JPEG"  -co "TILED=YES" -co "BLOCKXSIZE=512" -co "BLOCKYSIZE=512" -a_srs "EPSG:3057" D:\raster\image.tif 
D:\raster\image_translate.tif

When previewing the image with openlayers, I got nothing, just a blank basemap. The log from GeoServer told me that something in the projection went bad:

2017-06-09 13:16:47,551 INFO [geoserver.wms] - 
Request: getServiceInfo
2017-06-09 13:16:47,561 WARN [lite.gridcoverage2d] - Could not reduce the grid geometry inside the valid area bounds: ReferencedEnvelope[-1.7976931348623157E308 : 1.7976931348623157E308, -85.0 : 85.0]
Grid geometry isGridGeometry2D[GeneralGridEnvelope[0..357, 0..357], PARAM_MT["Affine", 
  PARAMETER["num_row", 3], 
  PARAMETER["num_col", 3], 
  PARAMETER["elt_0_0", 0.7353351955307262], 
  PARAMETER["elt_0_2", 584219.1848475977], 
  PARAMETER["elt_1_1", -0.7353351955307262], 
  PARAMETER["elt_1_2", 383937.61122240225]]]
2017-06-09 13:16:47,566 ERROR [geoserver.ows] - 
org.geoserver.platform.ServiceException: Error rendering coverage on the fast path

I then tried to use another compression strategy with GDAL, i.e. "DEFLATE":

gdal_translate -of GTiff -co COMPRESS=DEFLATE -co PREDICTOR=2 -co ZLEVEL=9 -co "BIGTIFF=YES" -a_srs "EPSG:3057"  D:\raster\image.tif D:\raster\image_translate2.tif

And that worked when previewing in openlayers. Here is the GeoServer log:

2017-06-09 13:28:27,137 INFO [geoserver.wms] - 
Request: getServiceInfo
2017-06-09 13:28:27,146 WARN [lite.gridcoverage2d] - Could not reduce the grid geometry inside the valid area bounds: ReferencedEnvelope[-1.7976931348623157E308 : 1.7976931348623157E308, -85.0 : 85.0]
Grid geometry isGridGeometry2D[GeneralGridEnvelope[0..357, 0..357], PARAM_MT["Affine", 
  PARAMETER["num_row", 3], 
  PARAMETER["num_col", 3], 
  PARAMETER["elt_0_0", 0.7353351955307262], 
  PARAMETER["elt_0_2", 584219.1848475977], 
  PARAMETER["elt_1_1", -0.7353351955307262], 
  PARAMETER["elt_1_2", 383937.61122240225]]]
2017-06-09 13:28:27,231 INFO [geoserver.wms] - 
Request: getMap

I have also tried to perform gdal_translate using JPEG compression and no tiling, and I got also errors with the GeoServer log and the openlayers preview displayed nothing.

So my question is, what is the best strategy to compress GeoTIFF files to be used in a WMS? At the moment, seems that DEFLATE is the only one working, but the compression is not the best. Has anyone been able to successfully upload a JPEG compressed GeoTIFF to Geoserver?

pahu87
  • 41
  • 6

2 Answers2

0

If it's any help the way I do it is as follows.

First I chop the raster up into smaller tiles, size is not important, for me it's generally either 256x256, 512x512 or 1024x124.

I use a number of different programs from gdal2tiles.py to my own homegrown c# apps.

What's important is that the tiles are square.

Once I have the tiles in a folder, I then use gdaltindex

This creates a shapefile with one square for each tile, correctly georeferenced (assuming your raster was) along with the name of each tile, I usually tell gdaltindex to write absolute paths to the shapefile.

I then reference the shape as a tile layer in mapserver, I can't say if geoserver will accept a shape based tile index, but since gdal can make them and the other WMS based server available open source (mapserver) can use them, then I would be very suprised if geoserver was not able to use them.

shawty
  • 5,729
  • 2
  • 37
  • 71
0

This would work in the case of tiff greater than 2GB. GeoServer can efficiently deal with large TIFF with overviews, as long as the TIFF is below the 2GB size limit. Using image pyramid makes the tiff load faster as it makes multiple mosaic of images at different zoom levels. Use the following command:-

mkdir bmpyramid
gdal_retile.py -v -r bilinear -levels 4 -ps 2048 2048 -co "TILED=YES" -co "COMPRESS=JPEG" -targetDir bmpyramid bmreduced.tiff

You can check here https://docs.geoserver.org/stable/en/user/tutorials/imagepyramid/imagepyramid.html

Zucoop
  • 11
  • 2