# @developmentseed/deck\.gl-geotiff 中文文档

规范地址：https://npmcn.com/package/%40developmentseed/deck.gl-geotiff/

版本：0\.10\.0
npm 元数据更新时间：2026-11-09T17:57:06.917Z
中文译文更新时间：2026-11-12T02:52:29.488Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40developmentseed/deck.gl-geotiff
原文对照：https://npmcn.com/package/%40developmentseed/deck.gl-geotiff/?lang=original
项目主页：https://github.com/developmentseed/deck.gl-raster#readme
源码仓库：https://github.com/developmentseed/deck.gl-raster

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：201 kB，63 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：7 个
- 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
- 首次发布：2025-12-18T20:45:21.962Z
- 最新版本发布：2026-11-09T17:57:06.536Z
- 近 30 天下载量：23136（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：28（近 12 个月 28 个）

## 中文简介

GeoTIFF和Cloud-Optimized GeoTIFF在甲板上的可视化.gl

## 安装

```sh
npm install @developmentseed/deck.gl-geotiff
```

也可以使用：`pnpm add @developmentseed/deck.gl-geotiff`、`yarn add @developmentseed/deck.gl-geotiff`、`bun add @developmentseed/deck.gl-geotiff`

## README

# @ 开发种子/ deck. gl- geotiff

用于渲染的高级API [云光化地层](https://cogeo.org/) (原始内容存档于2018-09-21). in deck.gl.

这个用 `@developmentseed/geotiff` 财务报告和审定财务报表 [`@cogeotiff/core`](https://github.com/blacha/cogeotiff) 从浏览器中高效地读取 Cloud-Optimized GeoTIFFs.

## 快速启动

```typescript
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'
    })
  ]
});
```

这个 [`COGLayer`](https://developmentseed.org/deck.gl-raster/api/deck-gl-geotiff/classes/COGLayer/) 是用于渲染 Cloud-Optimized GeoTIFFs 的推荐层。 它能操纵甲板 Gl's (英语) [`TileLayer`](https://deck.gl/docs/api-reference/geo-layers/tile-layer) 以匹配内部 COG 结构,根据缩放级别自动获取适当的概览.

## 层和源

每一层将其数据取为 `source`:一个打开的源,或者打开一个源的输入,例如URL.

| 层 | 来源 | 绘图 |
| --- | --- | --- |
| [`COGLayer`](https://developmentseed.org/deck.gl-raster/api/deck-gl-geotiff/classes/COGLayer/) | [`COGSource`](https://developmentseed.org/deck.gl-raster/api/deck-gl-geotiff/classes/COGSource/) | 一个COG. |
| [`MultiCOGLayer`](https://developmentseed.org/deck.gl-raster/api/deck-gl-geotiff/classes/MultiCOGLayer/) | [`MultiCOGSource`](https://developmentseed.org/deck.gl-raster/api/deck-gl-geotiff/classes/MultiCOGSource/) | 一个场景的乐队被作为单独的COG存储,例如Sentinel-2场景的乐队文件. |
| [`MosaicLayer`](https://developmentseed.org/deck.gl-raster/api/deck-gl-geotiff/classes/MosaicLayer/) | 无论它 `getSource` 打开 | 许多图像,例如STAC搜索的COG或GDAL VRT. 它只打开视图中的项目. |

打开一个源, 在绘制前读取其界限, 通过选项, 如 `epsgResolver`,或分层共享:

```ts
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` 将其项目作为 `data`,每个带WGS84 `bbox` 和一个独特的 `id`。 。 。 . [`parseVRT`](https://developmentseed.org/deck.gl-raster/api/deck-gl-geotiff/functions/parseVRT/) 将 GDAL VRT 摩赛克 的文件读取为项目 :

```ts
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 }),
});
```

## 使用虚拟

此软件包在 Web Worker 中解码图像平板 。 工人采用Vite默认工人格式的顶级等待和动态进口(`iife`)不支持,因此 `vite build` 失败错误, 如 `Top-level await is currently not supported with the 'iife' output format` (第8项)或 `Invalid value "iife" for option "worker.format"` (第7节) 设定 [`worker.format`](https://vite.dev/config/worker-options#worker-format) 改为 `"es"`数字 :

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

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

`vite dev` 工作没有这种设置,因为它不捆接工人.

## 请求、缓存和认证

通过一个共享的 COG 层读取 [`RangeReader`](https://developmentseed.org/deck.gl-raster/api/range-reader/): 读取所选的瓷砖 需求会一起发布,并合并成少数流式HTTP范围请求, 每个平方块都会随着字节的到来而解决,一个请求一旦被取消 它的瓷砖离开视图, 所有收到的都是缓存的, 所以一个锅回 超过已下载的瓷砖, 不需要请求 。 每个 `COGLayer`, (中文(简体) ), `MultiCOGLayer` 财务报告和审定财务报表 `MosaicLayer` 在一个页面上分享读者缓存和 默认批量窗口.

-   **通灵.** 用自己的读者打开源头 其间隙和超时限制或缓存预算,或隔离一层 (单位:千美元)`MosaicLayer` 带 `reader` 作为道具并传递给 `getSource`:
    
    ```ts
    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` 数请求、 请求和收到的字节、 字节 过度牵引和缓存点击.
    
-   **鉴定.** `requestInit` 打开 `COGSource.open` 财务报告和审定财务报表 `MultiCOGSource.open` (和 `MosaicLayer` 同名道具) 来源提出的每一项请求的标题、证书和模式. 不同inits读取的源从不共享请求或缓存字节, 甚至一个URL.
    
    ```ts
    const source = await COGSource.open(url, {
      requestInit: { headers: { authorization: `Bearer ${token}` } },
    });
    new COGLayer({ id: "private", source });
    ```
    
-   **作喉咙.** `COGLayer` 财务报告和审定财务报表 `MultiCOGLayer` 默认为 `maxRequests: 256` 财务报告和审定财务报表 `debounceTime: 50` 因此,整个选择到达 在一个任务中的阅读器和一个锅在要求什么之前就解决; 原产地 `concurrencyLimiter` (默认一次6次,匹配) 浏览器的 HTTP/1.1 限制) 将合并请求封顶。 一个平板 其负载不再被通缉,一旦离开视线就会中止. `MosaicLayer`属于自己的 `maxRequests` 仍然限制打开的源数 一次 一次吗.

## 常见问题

### @developmentseed/deck\.gl-geotiff 是什么？

GeoTIFF和Cloud-Optimized GeoTIFF在甲板上的可视化\.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 和提交记录判断。

