Show:
Extends stream.Readable

Multiplexer stream

Reads multiple input RasterReadStream streams and outputs a single synchronized stream with multiple data elements

All the input streams must have the same length

Can be used with RasterTransform which will automatically apply a function over the whole chunk

Table of Contents

Constructor

gdal.RasterMuxStream
(
  • inputs
  • options
)

Parameters:

  • inputs Record

    Input streams

  • [options] RasterReadableOptions optional
    • [blockOptimize=true] Boolean optional

      Read by file blocks when possible (when rasterSize.x == blockSize.x)

Example:

 const dsT2m = gdal.open('AROME_T2m_10.tiff'));
 const dsD2m = gdal.open('AROME_D2m_10.tiff'));

 const dsCloudBase = gdal.open('CLOUDBASE.tiff', 'w', 'GTiff',
   dsT2m.rasterSize.x, dsT2m.rasterSize.y, 1, gdal.GDT_Float64);

 const mux = new gdal.RasterMuxStream({
   T2m: dsT2m.bands.get(1).pixels.createReadStream(),
   D2m: dsD2m.bands.get(1).pixels.createReadStream()
 });
 const ws = dsCloudBase.bands.get(1).pixels.createWriteStream();

 // Espy's estimation for cloud base height (lifted condensation level)
 // LCL = 125 * (T2m - Td2m)
 // where T2m is the temperature at 2m and Td2m is the dew point at 2m
 const espyEstimation = new Transform({
   objectMode: true,
   transform(chunk, _, cb) {
     const lcl = new Float64Array(chunk.T2m.length)
     for (let i = 0; i < chunk.T2m.length; i++) {
       lcl[i] = 125 * (chunk.T2m[i] - chunk.D2m[i])
     }
     cb(null, lcl)
   }
 })

 mux.pipe(espyEstimation).pipe(ws);