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?
Steps Taken:
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
- Loaded image to S3
Tested image directly in QGIS The images display as desired in QGIS using the COG from S3 e.g.
Tested image as COG from s3 in QGIS - it works.
Concluded it must be a GeoServer issue (note I am running GeoServer 2.14)
The GeoServer layer is setup with the following properties
The GeoServer style is using the default raster configuration.