1.0.0 • Published 6 years ago

glad-stream-decoder v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

glad-stream-decoder

standard-readme compliant

Transform stream that decodes GLAD forest alerts

Global Forest Watch publishes weekly deforestation alerts as PNG map tiles. The data of the alert, the confidence level and intensity is encoded to the tile. This module decodes that information and creates an image tile with the alerts colored with the alpha transparency representing their intensity.

The transform stream expects raw image data, as you would get from reading the image data from the canvas. To decode a PNG to raw image data, and to re-encode the output to PNG, use png-stream

Table of Contents

Install

npm i glad-stream-decoder

Usage

var fs = require('fs')
var path = require('path')
var GLADStreamDecoder = require('glad-stream-decoder')
var PNGDecoder = require('png-stream/decoder')
var PNGEncoder = require('png-stream/encoder')

// encoded.png is an PNG encoded with date, confidence + intensity from
// http://wri-tiles.s3.amazonaws.com/glad_prod/tiles/{z}/{x}/{y}.png
var rs = fs.createReadStream('encoded.png'))
var ws = fs.createWriteStream('decoded.png'))

rs
  .pipe(new PNGDecoder())
  .pipe(new DecodeGLADStream({
    // Only show alerts since this date
    since: new Date(2017, 0, 1),
    // Color alerts green
    color: '#00FF00'
  }))
  .pipe(new PNGEncoder())
  .pipe(ws)

API

Table of Contents

GLADStreamDecoder

Transforms an encoded rgb image stream (a buffer of r,g,b values in order) from GLAD alerts into an rgba image stream with alerts as colored pixels opts.color and the intensity as the transparency of the pixel.

Parameters

Maintainers

@gmaclennan

Contribute

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2018 Digital Democracy