1

Goal: Cloud Optimised Geot4iffs (COG) that display without edge artefacts in Geoserver.

Problem: It doesn't display nicely: GeoServer appears to be ignoring the internal mask on the input GeoTIFF

Question: Why is GeoServer not picking up the internal masking of the COG?

image appears to be ignoring internal masks

Steps Taken:

  1. Built cloud optimised GeoTIFF using the following commands.

    gdalbuildvrt doq_index.vrt *.tif

    gdal_translate -r lanczos -b 1 -b 2 -b 3 -mask mask -of gtiff -ot / Byte -co "NUM_THREADS=ALL_CPUS" -co "SPARSE_OK=TRUE" -co "TILED=YES" / -co "BLOCKXSIZE=512" -co "TILED=YES" -co "BLOCKYSIZE=512" / doq_index.vrt out.tif

    gdaladdo -r lanczos --config COMPRESS_OVERVIEW JPEG --config / PHOTOMETRIC_OVERVIEW YCBCR -–config JPEG_QUALITY_OVERVIEW 50 / out.tif 2 4 8 16 32 64

    gdal_translate -r lanczos -co TILED=YES -co COMPRESS=JPEG -co / "NUM_THREADS=ALL_CPUS" -co PHOTOMETRIC=YCBCR -co JPEG_QUALITY=50 / -co COPY_SRC_OVERVIEWS=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 / --config GDAL_TIFF_OVR_BLOCKSIZE 512 --config GDAL_TIFF_INTERNAL_MASK / YES out.tif out_512-50.tif

The resulting gdalinfo looks like this

    c:\temp4>gdalinfo out_512-50.tif
Driver: GTiff/GeoTIFF
Files: out_512-50.tif
Size is 53760, 28800
Coordinate System is:
BOUNDCRS[
    SOURCECRS[
        PROJCRS["NZGD2000 / New Zealand Transverse Mercator 2000",
            BASEGEOGCRS["NZGD2000",
                DATUM["New Zealand Geodetic Datum 2000",
                    ELLIPSOID["GRS 1980",6378137,298.257222101,
                        LENGTHUNIT["metre",1]]],
                PRIMEM["Greenwich",0,
                    ANGLEUNIT["degree",0.0174532925199433]],
                ID["EPSG",4167]],
            CONVERSION["New Zealand Transverse Mercator 2000",
                METHOD["Transverse Mercator",
                    ID["EPSG",9807]],
                PARAMETER["Latitude of natural origin",0,
                    ANGLEUNIT["degree",0.0174532925199433],
                    ID["EPSG",8801]],
                PARAMETER["Longitude of natural origin",173,
                    ANGLEUNIT["degree",0.0174532925199433],
                    ID["EPSG",8802]],
                PARAMETER["Scale factor at natural origin",0.9996,
                    SCALEUNIT["unity",1],
                    ID["EPSG",8805]],
                PARAMETER["False easting",1600000,
                    LENGTHUNIT["metre",1],
                    ID["EPSG",8806]],
                PARAMETER["False northing",10000000,
                    LENGTHUNIT["metre",1],
                    ID["EPSG",8807]]],
            CS[Cartesian,2],
                AXIS["northing (N)",north,
                    ORDER[1],
                    LENGTHUNIT["metre",1]],
                AXIS["easting (E)",east,
                    ORDER[2],
                    LENGTHUNIT["metre",1]],
            USAGE[
                SCOPE["unknown"],
                AREA["New Zealand - onshore"],
                BBOX[-47.33,166.37,-34.1,178.63]],
            ID["EPSG",2193]]],
    TARGETCRS[
        GEOGCRS["WGS 84",
            DATUM["World Geodetic System 1984",
                ELLIPSOID["WGS 84",6378137,298.257223563,
                    LENGTHUNIT["metre",1]]],
            PRIMEM["Greenwich",0,
                ANGLEUNIT["degree",0.0174532925199433]],
            CS[ellipsoidal,2],
                AXIS["geodetic latitude (Lat)",north,
                    ORDER[1],
                    ANGLEUNIT["degree",0.0174532925199433]],
                AXIS["geodetic longitude (Lon)",east,
                    ORDER[2],
                    ANGLEUNIT["degree",0.0174532925199433]],
            USAGE[
                SCOPE["unknown"],
                AREA["World"],
                BBOX[-90,-180,90,180]],
            ID["EPSG",4326]]],
    ABRIDGEDTRANSFORMATION["Transformation to WGS84",
        METHOD["Position Vector transformation (geog2D domain)",
            ID["EPSG",9606]],
        PARAMETER["X-axis translation",0,
            ID["EPSG",8605]],
        PARAMETER["Y-axis translation",0,
            ID["EPSG",8606]],
        PARAMETER["Z-axis translation",0,
            ID["EPSG",8607]],
        PARAMETER["X-axis rotation",0,
            ID["EPSG",8608]],
        PARAMETER["Y-axis rotation",0,
            ID["EPSG",8609]],
        PARAMETER["Z-axis rotation",0,
            ID["EPSG",8610]],
        PARAMETER["Scale difference",1,
            ID["EPSG",8611]]]]
Data axis to CRS axis mapping: 2,1
Origin = (1794400.000000000000000,5538480.000000000000000)
Pixel Size = (0.125000000000000,-0.125000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=YCbCr JPEG
  INTERLEAVE=PIXEL
  SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left  ( 1794400.000, 5538480.000) (175d17'12.27"E, 40d16'53.70"S)
Lower Left  ( 1794400.000, 5534880.000) (175d17'16.21"E, 40d18'50.37"S)
Upper Right ( 1801120.000, 5538480.000) (175d21'56.62"E, 40d16'47.98"S)
Lower Right ( 1801120.000, 5534880.000) (175d22' 0.69"E, 40d18'44.65"S)
Center      ( 1797760.000, 5536680.000) (175d19'36.45"E, 40d17'49.20"S)
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
  NoData Value=255
  Overviews: 26880x14400, 13440x7200, 6720x3600, 3360x1800, 1680x900, 840x450
  Mask Flags: PER_DATASET
  Overviews of mask band: 26880x14400, 13440x7200, 6720x3600, 3360x1800, 1680x900, 840x450
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
  NoData Value=255
  Overviews: 26880x14400, 13440x7200, 6720x3600, 3360x1800, 1680x900, 840x450
  Mask Flags: PER_DATASET
  Overviews of mask band: 26880x14400, 13440x7200, 6720x3600, 3360x1800, 1680x900, 840x450
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
  NoData Value=255
  Overviews: 26880x14400, 13440x7200, 6720x3600, 3360x1800, 1680x900, 840x450
  Mask Flags: PER_DATASET
  Overviews of mask band: 26880x14400, 13440x7200, 6720x3600, 3360x1800, 1680x900, 840x450
  1. Loaded image to S3
  2. Configured GeoServer access to image, tested it - result: image appears to be ignoring internal masks

  3. Tested image directly in QGIS The images display as desired in QGIS using the COG from S3 e.g. enter image description here

  4. Tested image as COG from s3 in QGIS - it works.

  5. Concluded it must be a GeoServer issue (note I am running GeoServer 2.14)

The GeoServer layer is setup with the following properties enter image description here

The GeoServer style is using the default raster configuration.

1 Answer 1

1

As far as I remember, mask bands can only be used inside a image mosaic. You could make a image mosaic of one Tiff, and then configure mask usage (it's not on by default).

1
  • Thanks Andrea, given that the imagery in question are terabytes I am hoping to store on S3 as COGs - have you got any other suggestions that might help get me on the right track?
    – nstillwell
    Jan 6, 2020 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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