I have downloaded around 300 GeoTIFF images of totally 60 Gb. Together they make up a layer which I would like to serve as a WMS on my GeoServer. The images show where there are likely to be water. Where there are "no" water image is transparent.
I'm not sure where to go from here.
I read about how to compress and turn file into Tiles here: GeoTiff size - what to do?
When I run the command gdal_translate -co "TILED=YES" -co "COMPRESS=JPEG" input_filename.tiff output_filename.tiff
I get an error saying: "ERROR 1: JPEGSetupEncode:BitsPerSample 16 not allowed for JPEG"
I assume it won't work to keep the transparency with JPEG, so compression should be done in another way. I tried to change the command to "COMPRESS=PNG" but it didn't recognize it.
Next challenge I have is that I don't know much about WMS. Previously, I have uploaded one big geotiff on Geoserver and made it into a WMS, but I assume that using tiles is the way to go with very big layers?
Basically, I don't know much really. I have my 300 files and I need to turn them into a reasonable WMS. Any thoughts about the process or perhaps can point me in the right direction?
I use Leaflet to display my maps and layers.
UPDATE
This is the info when I run gdalinfo
on the original file:
Driver: GTiff/GeoTIFF
Files: MF_64_4_2575.tif
MF_64_4_2575.tif.ovr
MF_64_4_2575.tif.aux.xml
Size is 12500, 12500
Coordinate System is:
PROJCS["SWEREF99_TM",
GEOGCS["GCS_SWEREF99",
DATUM["SWEREF99",
SPHEROID["GRS_1980",6378137,298.257222101,
AUTHORITY["EPSG","7019"]],
AUTHORITY["EPSG","6619"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",15],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]]]
Origin = (475000.000000000000000,6450000.000000000000000)
Pixel Size = (2.000000000000000,-2.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 475000.000, 6450000.000) ( 14d34'29.25"E, 58d11'25.86"N)
Lower Left ( 475000.000, 6425000.000) ( 14d34'38.83"E, 57d57'57.50"N)
Upper Right ( 500000.000, 6450000.000) ( 15d 0' 0.00"E, 58d11'28.41"N)
Lower Right ( 500000.000, 6425000.000) ( 15d 0' 0.00"E, 57d58' 0.03"N)
Center ( 487500.000, 6437500.000) ( 14d47'17.02"E, 58d 4'43.59"N)
Band 1 Block=512x512 Type=Int16, ColorInterp=Gray
Min=0.000 Max=4356.000
Minimum=0.000, Maximum=4356.000, Mean=294.284, StdDev=337.062
NoData Value=-1
Overviews: 6250x6250, 3125x3125, 1563x1563, 782x782, 391x391, 196x196
Metadata:
RepresentationType=THEMATIC
STATISTICS_COVARIANCES=113610.8509799272
STATISTICS_MAXIMUM=4356
STATISTICS_MEAN=294.2839847232
STATISTICS_MINIMUM=0
STATISTICS_SKIPFACTORX=1
STATISTICS_SKIPFACTORY=1
STATISTICS_STDDEV=337.06208772261
I have tried compress it with LZW this way:
gdal_translate MF_64_4_2575.tif lzw_test3_tiled.tif -mask 1 -co COMPRESS=LZW -co "TILED=YES"
The result is however not a smaller file, but slightly bigger. This is also the conclusion here: https://havecamerawilltravel.com/photographer/tiff-image-compression/
So, next in line would be to convert it from 16 bit to 8 bit. I found and tried this:
gdal_translate -of GTiff -ot Byte -scale 0 65535 0 255 MF_64_4_2575.tif 8bit_test.tif
Although the file size was reduced to 156 mb instead of 240 mb it didn't kept it transparent where it originally was, and also it seems like it inverted the data and now had data where it should be transparent.
I also tried to add --config GDAL_TIFF_INTERNAL_MASK YES
but that didn't kept the transparency either.
I am out of ideas on how to go from my +300 geotiffs (60Gb) to a reasonable sized WMS served on GeoServer. If any thoughts, please share.
Image should look like the attached, but doesn't need to contain any other information besides the colors, the mask and having in correctly georeferenced.
gdal_translate -of PNG -ot UInt16 -co "WORLDFILE=YES" input_file.tif output_file.png
does turn it into .png and also reduces the size of about 50%. Even with 50% reduced size it is still about 30 gb. I have no clue, but it still feels large. Not sure I'm on the right path...