在 OpenLayers 中获取多频段 GeoTIFF 的透明度

问题描述 投票:0回答:1

使用此 3 频段 GeoTIFF:

Driver: GTiff/GeoTIFF
Files: mb_p_cr.tif
       mb_p_cr.tif.ovr
Size is 6196, 8003
Coordinate 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,1
Origin = (-83.175514742389765,-4.909911889634341)
Pixel Size = (0.001837484779547,-0.001807935284019)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner 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=100
Band 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=100
Band 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

如何修改以下 OpenLayers 调用以获得透明度?

new WebGLTileLayer({
  style: relief,
  source: new GeoTIFF({
    sources: [{
      url: 'raster/mb_p_cr.tif',
      overviews: ['raster/mb_p_cr.tif.ovr'],
    }],
  }),
}),

事实上,它显示黑色背景:

使用以下 OL 造型还不够(或者正确?):

const relief = {
  color: [
    'case',
    ['>', ['band', 4], 0],
    [0, 0, 0, 0.0],
  ],
};

这种方式也行不通:

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],
    ],
  ],
};

非常欢迎任何支持,

openlayers raster styling geotiff
1个回答
0
投票

这个不见了:

convertToRGB: true,
© www.soinside.com 2019 - 2024. All rights reserved.