Using this 3-band GeoTIFF:
Driver: GTiff/GeoTIFFFiles: mb_p_cr.tif mb_p_cr.tif.ovrSize is 6196, 8003Coordinate System is: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]], ID["EPSG",4326]]Data axis to CRS axis mapping: 2,1Origin = (-83.175514742389765,-4.909911889634341)Pixel Size = (0.001837484779547,-0.001807935284019)Metadata: AREA_OR_POINT=AreaImage Structure Metadata: INTERLEAVE=PIXELCorner Coordinates:Upper Left ( -83.1755147, -4.9099119) ( 83d10'31.85"W, 4d54'35.68"S)Lower Left ( -83.1755147, -19.3788180) ( 83d10'31.85"W, 19d22'43.74"S)Upper Right ( -71.7904590, -4.9099119) ( 71d47'25.65"W, 4d54'35.68"S)Lower Right ( -71.7904590, -19.3788180) ( 71d47'25.65"W, 19d22'43.74"S)Center ( -77.4829869, -12.1443649) ( 77d28'58.75"W, 12d 8'39.71"S)Band 1 Block=6196x1 Type=Byte, ColorInterp=Red Computed Min/Max=0.000,255.000 Minimum=0.000, Maximum=255.000, Mean=1.252, StdDev=12.524 Overviews: 3098x4002, 1549x2001, 775x1001, 388x501, 194x251 Metadata: STATISTICS_MAXIMUM=255 STATISTICS_MEAN=1.2524864788035 STATISTICS_MINIMUM=0 STATISTICS_STDDEV=12.523906791266 STATISTICS_VALID_PERCENT=100Band 2 Block=6196x1 Type=Byte, ColorInterp=Green Computed Min/Max=0.000,255.000 Minimum=0.000, Maximum=255.000, Mean=1.538, StdDev=15.985 Overviews: 3098x4002, 1549x2001, 775x1001, 388x501, 194x251 Metadata: STATISTICS_MAXIMUM=255 STATISTICS_MEAN=1.5377140689737 STATISTICS_MINIMUM=0 STATISTICS_STDDEV=15.98530773052 STATISTICS_VALID_PERCENT=100Band 3 Block=6196x1 Type=Byte, ColorInterp=Blue Computed Min/Max=0.000,255.000 Minimum=0.000, Maximum=255.000, Mean=1.856, StdDev=17.187 Overviews: 3098x4002, 1549x2001, 775x1001, 388x501, 194x251 Metadata: STATISTICS_MAXIMUM=255 STATISTICS_MEAN=1.8563095125642 STATISTICS_MINIMUM=0 STATISTICS_STDDEV=17.187388492599 STATISTICS_VALID_PERCENT=100
how can the following OpenLayers call be modified to get transparency?
new WebGLTileLayer({ style: relief, source: new GeoTIFF({ sources: [{ url: 'raster/mb_p_cr.tif', overviews: ['raster/mb_p_cr.tif.ovr'], }], }),}),
As it is, it displays a black background:
Using the following OL styling is not enough (or correct?):
const relief = { color: ['case', ['>', ['band', 4], 0], [0, 0, 0, 0.0], ],};
and this way does not work either:
const relief = { color: ['case', ['all', ['==', ['band', 1], 0], ['==', ['band', 2], 0], ['==', ['band', 3], 0], ['==', ['band', 4], 1], ], [0, 0, 0, 0.0], ['color', ['*', ['band', 1], 255], ['*', ['band', 2], 255], ['*', ['band', 3], 255], ['band', 4], ], ],};
Unfortunately, including convertToRGB: true
to the OL call and assigning nodata: 0
to the GeoTIFF were not enough. For some reason that cannot be discovered yet, the GeoTIFF dissapeared after several tests and now Chrome's console says:
GET http://localhost:5173/raster/.test/mb_p_cr.tif 416 (Range Not Satisfiable)Promise.then (async) (anonymous) @ main.js:582Show 13 more frames
Any clues? any hint is very welcomed,