I would like to use the calculated min/max values of an image region to set the min/max visualization parameters of that image. I can retrieve the actual numbers, but can't use them as variables in the visualization parameters block. I keep getting the error:
Shaded: Layer error: Can't encode object: abs()
Computes the absolute value of the input.
Args: this:input (Number): The input value.
Here's the code I'm using:
var fc = ee.FeatureCollection('TIGER/2018/States') .filter(ee.Filter.and(ee.Filter.eq('NAME', 'Utah'))); var DEM = ee.Image('USGS/NED').clip(fc); var Terrain = ee.Terrain.products(DEM).select('slope'); print(Terrain); var visPct = Terrain.reduceRegion({reducer: ee.Reducer.percentile([5,95]).setOutputs(['min','max']), geometry: fc, scale: 10, bestEffort: true }); var Min = visPct.getNumber('slope_min'); var Max = visPct.getNumber('slope_max'); print(Min,Max); var vizParams = { min: Min, max: Max, palette: ['blue','green','Yellow','red'] }; Map.centerObject(fc); Map.addLayer(Terrain, vizParams, 'Shaded'); The only thing that I can figure out is that GEE is trying to display the image before the min/max values are calculated.
getInfo()orevaluate(). Make sure to read serverVSclient