TransWikia.com

How can I stretch the colors in my vizParams using EarthEngine API?

Geographic Information Systems Asked on June 9, 2021

I’m displaying images on a map :

var landsat = [];
//load all the landsat years 
for (var year = 2005; year < 2016; year++) { 
  var start = year.toString() + '-01-01';
  var end = year.toString() + '-12-31';
  
  var dataset = ee.ImageCollection('LANDSAT/LE07/C01/T1_SR')
                  .filterDate(start,end)
                  .map(cloudMaskL457);
                  
  var clip = dataset.median().clip(buffGeo)
  
  landsat[year.toString()] = clip;
  
  //Map.addLayer(clip, visParams, 'landsat-' + year.toString())
}

Map.addLayer(landsat['2010'], visParams, 'landsat')

To do so I’m using the following vizParams :

var params = landsat['2010'].reduceRegion({
    reducer: ee.Reducer.percentile([0, 100]), 
    geometry: buffer, 
    scale: Map.getScale(),
  });
print(params)

//vizparams for landsat
var visParams = {
  bands: ['B3', 'B2', 'B1'],
  min: [
    params.get('B3_p0').getInfo(), 
    params.get('B2_p0').getInfo(), 
    params.get('B1_p0').getInfo()
  ],
  max: [
    params.get('B3_p100').getInfo(), 
    params.get('B2_p100').getInfo(), 
    params.get('B1_p100').getInfo()
  ],
};

Map.addLayer(landsat['2010'], visParams, 'landsat stretch')

But I obtain a different stretch than when I use the button on the interactive map of the JavaScript code editor. Is it possible to reproduce this behaviour ?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP