cogeotiff
用于处理云优化GeoTIFF(COG)的工具
- 完全基于JavaScript,支持浏览器和nodejs
- 延迟加载Tiff图像和元数据
- 支持超大100GB+的COG
- 使用GDAL Tiff优化,通常每个瓦片只需一到两次读取!
- 支持从URL、文件、Google Cloud或AWS S3加载Tiff
- 已用于LINZ的底图生产环境,数十亿瓦片从COG中提取!
使用方法
使用fetch从URL加载COG
import { SourceHttp } from '@chunkd/source-http';const source = new SourceHttp('https://example.com/cog.tif');
const cog = await Tiff.create(source);
const img = cog.images[0];
if (img.isTiled()) throw new Error('Tiff is not tiled');
const tile = await img.getTile(2, 2); // Fetch a tile from a tiff x:2, y:2
// Tiff tags can be directly accessed too
img.value(TiffTag.GdalNoData); // "-9999"
// or tag metadata can be fetched
img.tags.get(TiffTag.GdalNoData);
/
{
type: 'inline', // How the tag was read "inline" vs "lazy"
id: 42113, // Tag Id (@see TiffTag)
name: 'GdalNoData', // Tag Name
count: 6, // Number of values
value: '-9999',
dataType: 2, // Char
tagOffset: 194 // Bytes into the file where the tag was read.
}
*/
命令行界面
npm i -g @cogeotiff/clicogeotiff 信息
显示关于 COG 的基本信息
cogeotiff info webp.cog.tif
输出:COG File Info - /home/blacha/Downloads/tif-new/bg43.webp.cog.tif Tiff type BigTiff (v43)
Chunk size 64 KB
Bytes read 64 KB (1 Chunk)
Images
Compression image/webp
Origin 18550349.52047286,-5596413.462927464,0
Resolution 19.10925707129406,-19.10925707129415,0
BoundingBox 18550349.52047286,-5713820.738373496,19098250.139221005,-5596413.462927464
Info
Id Size Tile Size Tile Count
0 28672x6144 56x12 672
1 14336x3072 28x6 168
2 7168x1536 14x3 42
3 3584x768 7x2 14
4 1792x384 4x1 4
5 896x192 2x1 2
6 448x96 1x1 1
GDAL
COG optimized true
COG broken false
Tile order RowMajor
Tile leader uint32 - 4 Bytes
Mask interleaved false
cogeotiff 转储
导出图像的所有瓦片(警告 如果对大型 cog 执行此操作,将生成数百万个文件。)
cogeotiff dump --image 2 --output output
构建
# Download the latest nodejs
n latestInstall node deps
npm installBuild everything into /build
npm run buildRun the unit tests
npm run test--- Tranlated By Open Ai Tx | Last indexed: 2026-07-28 ---