How to use geotiff - 9 common examples

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 geotiffjs / cog-explorer / src / actions / scenes / index.js View on Github external
usedPipeline = usedPipeline || landsat8Pipeline;
        } else {
          bands = new Map(
            files
              .filter(file => /.TIFF?$/gi.test(file))
              .map((file, i) => [i, file]),
          );
        }

        const hasOvr = typeof files.find(file => /.TIFF?.OVR$/i.test(file)) !== 'undefined';
        dispatch(
          addScene(url, bands, red, green, blue, false, hasOvr, false, attribution, usedPipeline)
        );
      } else if (contentType === 'image/tiff') {
        const tiff = await fromUrl(url);
        const image = await tiff.getImage();

        const samples = image.getSamplesPerPixel();
        const bands = new Map();
        for (let i = 0; i < samples; ++i) {
          bands.set(i, url);
        }

        let [red, green, blue] = [];
        if (samples === 3 || typeof image.fileDirectory.PhotometricInterpretation !== 'undefined') {
          red = 0;
          green = 1;
          blue = 2;
        } else {
          red = 0;
          green = 0;
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.");
github antvis / L7 / demos / raster / basic / demo / raster.js View on Github external
async function getTiffData() {
  const response = await fetch(
    'https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat',
  );
  const arrayBuffer = await response.arrayBuffer();
  const tiff = await GeoTIFF.fromArrayBuffer(arrayBuffer);
  const image = await tiff.getImage();
  const width = image.getWidth();
  const height = image.getHeight();
  const values = await image.readRasters();
  return {
    data: values[0],
    width,
    height,
    min: 0,
    max: 8000,
  };
}
github geotiffjs / cog-explorer / src / components / mapview.jsx View on Github external
async getImage(sceneId, url, hasOvr = true) {
    if (!this.sceneSources[sceneId]) {
      this.sceneSources[sceneId] = {};
    }
    if (!this.sceneSources[sceneId][url]) {
      if (hasOvr) {
        this.sceneSources[sceneId][url] = fromUrls(url, [`${url}.ovr`]);
      } else {
        this.sceneSources[sceneId][url] = fromUrl(url);
      }
    }
    return this.sceneSources[sceneId][url];
  }
github antvis / L7 / stories / Layers / components / RasterLayer.tsx View on Github external
private async getTiffData() {
    const response = await fetch(
      'https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat',
    );
    const arrayBuffer = await response.arrayBuffer();
    const tiff = await GeoTIFF.fromArrayBuffer(arrayBuffer);
    const image = await tiff.getImage();
    const width = image.getWidth();
    const height = image.getHeight();
    const values = await image.readRasters();
    return {
      data: values[0],
      width,
      height,
      min: 0,
      max: 8000,
    };
  }
}
github geotiffjs / cog-explorer / src / components / mapview.jsx View on Github external
async getImage(sceneId, url, hasOvr = true) {
    if (!this.sceneSources[sceneId]) {
      this.sceneSources[sceneId] = {};
    }
    if (!this.sceneSources[sceneId][url]) {
      if (hasOvr) {
        this.sceneSources[sceneId][url] = fromUrls(url, [`${url}.ovr`]);
      } else {
        this.sceneSources[sceneId][url] = fromUrl(url);
      }
    }
    return this.sceneSources[sceneId][url];
  }
github geotiffjs / cog-explorer / src / components / mapview.jsx View on Github external
maxZoom: 23,
      }),
    });
    this.sceneLayers = {};
    this.sceneSources = {};
    this.tileCache = {};
    this.renderedTileCache = {};

    this.progressBar = new ProgressBar();

    this.map.on('moveend', () => {
      const view = this.map.getView();
      this.props.setPosition(...view.getCenter(), view.getZoom());
    });

    this.pool = new Pool();
  }
github GeoTIFF / georaster / src / index.js View on Github external
return urlExists(ovrURL).then(ovrExists => {
        if (ovrExists) {
          return fromUrls(this._url, [ovrURL], {cache: true, forceXHR: false});
        } else {
          return fromUrl(this._url, {cache: true, forceXHR: false});
        }
      });
    } else {
github GeoTIFF / georaster / src / index.js View on Github external
return urlExists(ovrURL).then(ovrExists => {
        if (ovrExists) {
          return fromUrls(this._url, [ovrURL], {cache: true, forceXHR: false});
        } else {
          return fromUrl(this._url, {cache: true, forceXHR: false});
        }
      });
    } else {