Skip to content

High performance cloud optimized geotiff (COG) reader

License

Notifications You must be signed in to change notification settings

blacha/cogeotiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b4fa67e · Nov 14, 2023
Sep 7, 2023
Nov 14, 2023
Jul 20, 2023
Aug 26, 2019
Jun 15, 2022
Nov 4, 2020
Jun 19, 2019
Jul 20, 2023
Nov 14, 2023
Aug 26, 2019
Jan 29, 2021
Aug 23, 2023
Aug 5, 2023
Jul 20, 2023
Jul 20, 2023
Jul 20, 2023
Jul 20, 2023
Nov 14, 2023

Repository files navigation

cogeotiff

Tools to work with Cloud optimized GEOTiff

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

Usage

Load a COG from a URL using fetch

import { SourceHttp } from '@chunkd/source-http';

const source = new SourceHttp('https://example.com/cog.tif');
const cog = await CogTiff.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

Command Line Interface

npm i -g @cogeotiff/cli

cogeotiff info

Display basic information about COG

cogeotiff info webp.cog.tif

Output:

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 dump

Dump all tiles for a image (Warning if you do this for a large cog this will create millions of files.)

cogeotiff dump --image 2 --output output

Building

This requires NodeJs >= 18 & Yarn

Use n to manage nodeJs versions

# Download the latest nodejs & yarn
n latest
npm install -g yarn

# Install node deps
yarn

# Build everything into /build
yarn run build

# Run the unit tests
yarn run test