GeoZarr 重采样
GeoZarr 重采样示例。 Zarr GeoZarr sentinel-2
本示例使用的 GeoZarr 数据集并非所有波段在所有缩放级别都可用。当出现这种情况时,在合成数据瓦片时会对来自最接近分辨率级别的波段数据进行重采样。本示例展示了一个由蓝(b02)、绿(b03)和短波红外(b11)数据组成的假彩色合成影像。短波红外数据最高只有 20 米分辨率,而可见光的蓝色和绿色波段有 10 米分辨率。当地图放大到每像素小于 20 米时,会获取最高分辨率的短波红外数据,进行重采样,并与更高分辨率的可见光波段一起合成。
main.js
js
import Map from 'ol/Map.js';
import {getView, withExtentCenter, withHigherResolutions} from 'ol/View.js';
import Link from 'ol/interaction/Link.js';
import TileLayer from 'ol/layer/WebGLTile.js';
import GeoZarr from 'ol/source/GeoZarr.js';
import OSM from 'ol/source/OSM.js';
const source = new GeoZarr({
url: 'https://s3.explorer.eopf.copernicus.eu/esa-zarr-sentinel-explorer-fra/tests-output/sentinel-2-l2a/S2B_MSIL2A_20260120T125339_N0511_R138_T27VWL_20260120T131151.zarr/measurements/reflectance',
bands: ['b11', 'b03', 'b02'],
});
const map = new Map({
layers: [
new TileLayer({
source: new OSM(),
}),
new TileLayer({
style: {
gamma: 1.5,
color: [
'color',
['interpolate', ['linear'], ['band', 1], 0, 0, 0.5, 255],
['interpolate', ['linear'], ['band', 2], 0, 0, 0.5, 255],
['interpolate', ['linear'], ['band', 3], 0, 0, 0.5, 255],
],
},
source,
}),
],
target: 'map',
view: getView(source, withHigherResolutions(2), withExtentCenter()),
});
map.addInteraction(new Link());index.html
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GeoZarr 重采样</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": "geozarr-sparse",
"dependencies": {
"ol": "10.11.0"
},
"devDependencies": {
"vite": "^8.1.5"
},
"scripts": {
"start": "vite",
"build": "vite build"
}
}