npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cogeotiff/core

v9.0.3

Published

Working with [Cloud optimized GEOTiff](https://www.cogeo.org/) and Tiffs

Downloads

1,286

Readme

@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