How to use the geotiff.parse function in geotiff

To help you get started, we’ve selected a few geotiff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pixpipe / pixpipejs / src / decoder / TiffDecoder.js View on Github external
_run(){

    var inputBuffer = this._getInput(0);

    if(!inputBuffer){
      console.warn("TiffDecoder requires an ArrayBuffer as input \"0\". Unable to continue.");
      return;
    }
    
    var success = false;
    
    try{
      var tiffData = geotiff.parse(inputBuffer);
      var tiffImage = tiffData.getImage();
      
      var data = tiffImage.readRasters( {interleave: true} );
      var width = tiffImage.getWidth();
      var height = tiffImage.getHeight();
      var ncpp = tiffImage.getSamplesPerPixel();
      
      if(ncpp == (data.length / (width*height))){
        success = true;
      }
      
      if( success ){
        var outputImg = this._addOutput( Image2D );
        outputImg.setData( data, width, height, ncpp);
      }else{
        console.warn("Tiff support is experimental and this file is not compatible.");