Openlayers 单波段透明背景,概览 GeoTIFF

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

我有以下 GeoTIFF 图层:

new WebGLTileLayer({
  title: 'mb',
  style: slope,
  source: new GeoTIFF({
    normalize: false,
    sources: [{
      url: 'raster/mb_p_sl.tif',
      overviews: ['raster/mb_p_sl.tif.ovr'],
      min: 0,
      max: 76,
      nodata: -9999,
    }],
  }),
}),

白到黑的颜色样式如下(范围值0-76):

const slope = {
  color: [
    'interpolate',
    ['linear'],
    ['band', 1],
    0,
    [255, 255, 255],
    76,
    [0, 0, 0],
  ],
};

问题是白色背景覆盖了图层范围,如下所示:

不知道如何使背景透明,欢迎任何提示,

图层信息在这里:

Driver: GTiff/GeoTIFF
Files: raster/mb_p_sl.tif
       raster/mb_p_sl.tif.ovr
Size is 833, 1319
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 = (-77.598083833395464,-15.699601330547507)
Pixel Size = (0.000935666790919,-0.000903654660184)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( -77.5980838, -15.6996013) ( 77d35'53.10"W, 15d41'58.56"S)
Lower Left  ( -77.5980838, -16.8915218) ( 77d35'53.10"W, 16d53'29.48"S)
Upper Right ( -76.8186734, -15.6996013) ( 76d49' 7.22"W, 15d41'58.56"S)
Lower Right ( -76.8186734, -16.8915218) ( 76d49' 7.22"W, 16d53'29.48"S)
Center      ( -77.2083786, -16.2955616) ( 77d12'30.16"W, 16d17'44.02"S)
Band 1 Block=833x2 Type=Float32, ColorInterp=Gray
    Computed Min/Max=0.000,45.349
  Minimum=0.000, Maximum=45.349, Mean=4.120, StdDev=4.657
  NoData Value=-9999
  Overviews: 417x660, 209x330, 105x165
  Metadata:
    STATISTICS_MAXIMUM=45.349166870117
    STATISTICS_MEAN=4.1197140260889
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=4.6573973577461
    STATISTICS_VALID_PERCENT=9.514
openlayers gdal geotiff
1个回答
0
投票

指定

nodata
会添加另一个 alpha 波段,因此您可以使用

  color: [
    'case',
    ['>', ['band', 2], 0],
    [
      'interpolate',
      ['linear'],
      ['band', 1],
      0,
      [255, 255, 255],
      76,
      [0, 0, 0],
    ],
    [0, 0, 0, 0],
  ],
© www.soinside.com 2019 - 2024. All rights reserved.