@developmentseed/deck.gl-geotiff

中文文档
0.10.0发布于 2026/11/10MITTypeScriptES Module构建来源已验证近 30 天下载 2.3万

GeoTIFF and Cloud-Optimized GeoTIFF visualization in deck.gl

原始使用文档
文档目录4 节
  1. Quick Start
  2. Layers and sources
  3. Using Vite
  4. Requests, caching and authentication

@developmentseed/deck.gl-geotiff

High-level API for rendering Cloud-Optimized GeoTIFFs in deck.gl.

This uses @developmentseed/geotiff and @cogeotiff/core to efficiently read Cloud-Optimized GeoTIFFs from the browser.

Quick Start

import { Deck } from '@deck.gl/core';
import { COGLayer } from '@developmentseed/deck.gl-geotiff';

new Deck({
  initialViewState: {
    longitude: 0,
    latitude: 0,
    zoom: 2
  },
  controller: true,
  layers: [
    new COGLayer({
      id: 'cog-layer',
      source: 'https://example.com/my-cog.tif'
    })
  ]
});

The COGLayer is the recommended layer for rendering Cloud-Optimized GeoTIFFs. It leverages deck.gl's TileLayer to match the internal COG structure, automatically fetching appropriate overviews based on zoom level.

Layers and sources

Each layer takes its data as source: an opened source, or the input to open one from, such as a URL.

LayerSourceDraws
COGLayerCOGSourceOne COG.
MultiCOGLayerMultiCOGSourceThe bands of one scene stored as separate COGs, such as a Sentinel-2 scene's band files.
MosaicLayerWhatever its getSource opensMany images, such as the COGs of a STAC search or a GDAL VRT. It opens only the items in view.

Open a source yourself to read its bounds before drawing, to pass options such as an epsgResolver, or to share it between layers:

import { COGLayer, COGSource } from "@developmentseed/deck.gl-geotiff";

const source = await COGSource.open("https://example.com/my-cog.tif");
const { west, south, east, north } = source.geographicBounds;
new COGLayer({ id: "cog", source });

MosaicLayer takes its items as data, each with a WGS84 bbox and a unique id. parseVRT reads the files of a GDAL VRT mosaic as items:

import {
  COGLayer,
  COGSource,
  MosaicLayer,
  parseVRT,
} from "@developmentseed/deck.gl-geotiff";

const response = await fetch(vrtUrl);
const items = parseVRT(await response.text(), vrtUrl);

new MosaicLayer({
  id: "mosaic",
  data: items,
  getSource: (item, options) => COGSource.open(item.url, options),
  renderSource: (item, { source, subLayerProps }) =>
    new COGLayer({ ...subLayerProps, source }),
});

Using Vite

This package decodes image tiles in a Web Worker. The worker uses top-level await and dynamic imports, which Vite's default worker format (iife) doesn't support, so vite build fails with an error such as Top-level await is currently not supported with the 'iife' output format (Vite 8) or Invalid value "iife" for option "worker.format" (Vite 7). Set worker.format to "es":

// vite.config.ts
import { defineConfig } from "vite";

export default defineConfig({
  worker: { format: "es" },
});

vite dev works without this setting, because it doesn't bundle workers.

Requests, caching and authentication

The COG layers read through one shared RangeReader: the reads a selection of tiles needs are issued together and merged into few streamed HTTP range requests, each tile resolves as its bytes arrive, a request is cancelled as soon as its tiles leave the view, and everything received is cached, so a pan back over tiles already downloaded costs no request. Every COGLayer, MultiCOGLayer and MosaicLayer on a page shares that reader's cache and batching window by default.

  • Tuning. Open the source yourself with a reader of your own to change its gap and over-fetch limits or its cache budgets, or to isolate a layer (MosaicLayer takes reader as a prop and passes it to getSource):

    import { RangeReader } from "@developmentseed/range-reader";
    
    const reader = new RangeReader({
      maxOverfetchBytes: 4 * 1024 * 1024,
      cache: { metadataBytes: 64 * 1024 * 1024, dataBytes: 256 * 1024 * 1024 },
    });
    const source = await COGSource.open(url, { reader });
    new COGLayer({ id: "scene", source });
    

    reader.stats counts requests, bytes requested and received, bytes over-fetched and cache hits.

  • Authentication. requestInit on COGSource.open and MultiCOGSource.open (and the MosaicLayer prop of the same name) sets the headers, credentials and mode of every request the source makes. Sources read with different inits never share a request or a cached byte, even for one URL.

    const source = await COGSource.open(url, {
      requestInit: { headers: { authorization: `Bearer ${token}` } },
    });
    new COGLayer({ id: "private", source });
    
  • Throttling. COGLayer and MultiCOGLayer default to maxRequests: 256 and debounceTime: 50 so a whole selection reaches the reader in one task and a pan settles before anything is requested; the per-origin concurrencyLimiter (six at a time by default, matching the browser's HTTP/1.1 limit) caps the merged requests instead. A tile whose load is no longer wanted is aborted as soon as it leaves the view. MosaicLayer's own maxRequests still caps how many sources open at once.

版本与发布记录

@developmentseed/deck.gl-geotiff 共发布 28 个版本,首次发布于 2025/12/19;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.10.0latest2026/11/102 天前
0.10.0-beta.4beta2026/11/075 天前
0.10.0-beta.32026/11/066 天前
0.10.0-beta.22026/10/3012 天前
0.9.02026/10/2419 天前
0.9.0-beta.32026/10/2320 天前

关于 @developmentseed/deck.gl-geotiff 的常见问题

@developmentseed/deck.gl-geotiff 是什么?

GeoTIFF and Cloud-Optimized GeoTIFF visualization in deck.gl

如何安装 @developmentseed/deck.gl-geotiff?

在项目目录运行 npm install @developmentseed/deck.gl-geotiff,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@deck.gl/core(^9.4.0)、@luma.gl/core(^9.4.0)、@deck.gl/layers(^9.4.0)、@deck.gl/geo-layers(^9.4.0)、@deck.gl/mesh-layers(^9.4.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@developmentseed/deck.gl-geotiff 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@developmentseed/deck.gl-geotiff 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@developmentseed/deck.gl-geotiff 可以商用吗?

@developmentseed/deck.gl-geotiff 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@developmentseed/deck.gl-geotiff 的下载量有多少?

根据 npm 官方下载统计,@developmentseed/deck.gl-geotiff 在 2026/10/12 – 2026/11/10 这 30 天内被下载 23,136 次,日均约 771 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@developmentseed/deck.gl-geotiff 还在维护吗?

最新版本 0.10.0 发布于 2026/11/10(2 天前);至今共发布 28 个版本,其中过去 12 个月发布了 28 个;首次发布于 2025/12/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。