Skip to content

GeoTIFF 逐波段统计 ​

GeoTIFF 逐波段统计示例。 GeoTIFF 统计 visualization

本示例演示如何为 GeoTIFF 的每个波段使用不同的最小值和最大值进行渲染,从而在不使用样式的情况下改善数据的可视化效果。GeoTIFF 数据源支持为 min、max 和 nodata 提供数组值,因此每个波段都可以独立配置。

main.js
js
import Map from 'ol/Map.js';
import TileLayer from 'ol/layer/WebGLTile.js';
import GeoTIFF from 'ol/source/GeoTIFF.js';

const source = new GeoTIFF({
  sources: [
    {
      url: 'https://spacenet-dataset.s3.amazonaws.com/spacenet/SN3_roads/train/AOI_3_Paris/PS-RGB/SN3_roads_train_AOI_3_Paris_PS-RGB_img101.tif',
      nodata: 0,
      min: [110, 216, 217],
      max: [586, 579, 432],
    },
  ],
});

const map = new Map({
  target: 'map',
  layers: [new TileLayer({source})],
  view: source.getView(),
});
index.html
html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>GeoTIFF 逐波段统计</title>
    <link rel="stylesheet" href="node_modules/ol/ol.css">
    <style>
      .map {
        width: 100%;
        height: 400px;
      }
    </style>
  </head>
  <body>
    <div id="map" class="map"></div>

    <script type="module" src="main.js"></script>
  </body>
</html>
package.json
json
{
  "name": "geotiff-per-band-stats",
  "dependencies": {
    "ol": "10.11.0"
  },
  "devDependencies": {
    "vite": "^8.1.5"
  },
  "scripts": {
    "start": "vite",
    "build": "vite build"
  }
}