9.0.3 • Published 4 months ago

@cogeotiff/core v9.0.3

Weekly downloads
61
License
MIT
Repository
github
Last release
4 months ago

@cogeotiff/core

Working with Cloud optimized GEOTiff and Tiffs

  • Completely javascript based, works in the browser and nodejs
  • Lazy load Tiffs images and metadata
  • Supports huge 100GB+ COG
  • Uses GDAL COG optimizations, generally only one or two reads per tile!
  • Loads Tiffs from URL, File, Google Cloud or AWS S3
  • Used in production for LINZ's Basemaps with billions of tiles fetched from Tiffs!

Usage

Load a COG from a remote http source

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)

Tags

Tags are somewhat typesafe for most common use cases in typescript,

img.value(TiffTag.ImageWidth) // number
img.value(TiffTag.BitsPerSample) // number[]

Some tags have exported constants to make them easier to work with

import {Photometric} from '@cogeotiff/core'


const photometric = img.value(TiffTag.Photometric)

if( photometric == Photometric.Rgb) { 
  // Tiff is a RGB photometric tiff
}

For a full list of constants see ./src/index.ts

GeoTiff tags are loaded into a separate location

import {RasterTypeKey} from '@cogeotiff/core'

const pixelIsArea = img.valueGeo(TiffTagGeo.GTRasterTypeGeoKey) == RasterTypeKey.PixelIsArea

Examples

More examples can bee seen

9.0.3

4 months ago

9.0.2

5 months ago

9.0.1

5 months ago

9.0.0

5 months ago

8.1.0

9 months ago

8.0.1

9 months ago

8.1.1

6 months ago

8.0.2

9 months ago

7.2.1

1 year ago

7.2.0

2 years ago

7.1.0

2 years ago

7.0.0

2 years ago

6.1.1

2 years ago

6.1.0

3 years ago

6.0.2

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.0.0

3 years ago

4.3.0

3 years ago

4.2.0

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

3.1.0

3 years ago

3.0.0

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago