@ cogeotif/ 核心
与 云优化了 GEOTIff 和蒂夫斯语
- 完全基于 Javascript, 在浏览器和节点中工作
- 懒惰地装入 Tiffs 图像和元数据
- 支持巨大的 100GB+ COG
- 使用GDAL COG优化,一般每个瓦片只读取一到两个!
- 从 URL、 文件、 Google Cloud 或 AWS S3 装入 Tiffs
- 用于生产 LINZ的基图 从蒂夫斯取来数十亿块瓷砖!
使用量
从远程 http 源装入 COG
import { SourceHttp } from '@chunkd/source-url';
import { Tiff } from '@cogeotiff/core'
const source = new SourceHttp('https://example.com/cog.tif');
const tiff = await Tiff.create(source);
/** Load a specific tile from a specific image */
const tile = await tiff.images[5].getTile(2, 2);
/** Load the 5th image in the Tiff */
const img = tiff.images[5];
if (img.isTiled()) {
/** Load tile x:10 y:10 */
const tile = await img.getTile(10, 10);
tile.mimeType; // image/jpeg
tile.bytes; // Raw image buffer
}
/** Get the origin point of the tiff */
const origin = img.origin;
/** Bounding box of the tiff */
const bbox = img.bbox;
// Tiff tags can be accessed via some helpers
const noData = img.noData; // -9999
const noDataTag = img.tags.get(TiffTag.GdalNoData) // Tag information such as file offset or tagId
const noDataValue = img.value(TiffTag.GdalNoData) // "-9999" (tag is stored as a string)
标记
在打字符中,标记对于大多数常见的用例来说是一定的打字安全,
img.value(TiffTag.ImageWidth) // number
img.value(TiffTag.BitsPerSample) // number[]
有些标记会输出常数使其更容易使用
import {Photometric} from '@cogeotiff/core'
const photometric = img.value(TiffTag.Photometric)
if( photometric == Photometric.Rgb) {
// Tiff is a RGB photometric tiff
}
关于常数的完整列表,请参见 ./src/index.ts (中文(简体) )
GeoTiff 标记装入到一个单独的位置
import {RasterTypeKey} from '@cogeotiff/core'
const pixelIsArea = img.valueGeo(TiffTagGeo.GTRasterTypeGeoKey) == RasterTypeKey.PixelIsArea
实例
更多的例子可以看见
- @cogeotif/ 实例
- 科格维维尔
- @ chunkd (英语) 其他来源,例如文件://和s3://