1

I want to extract minimum and maximum values for all the bands in an image here is my code:

https://code.earthengine.google.com/8edcbe3386ba6e639dec363e3af0eb38

Map.setOptions('HYBRID');

//Get elevation data
var elevation = ee.Image("USGS/SRTMGL1_003").clip(roi)

//compute slope and aspect
var slope = ee.Terrain.slope(elevation);
var aspect = ee.Terrain.aspect(elevation);

var dataset= elevation
.addBands(slope.float().rename('slope'))
.addBands(aspect.float().rename('aspect'))

//Extract values of bands
var bands = dataset.bandNames()
var value = dataset.reduceRegions(pts, ee.Reducer.first(),1000);

//Print/get min and max values
var stat = value.aggregate_stats('aspect');

print(stat.get('min'),'min')
print(stat.get('max'),'max')

How would it be possible to get each band's min and max values together?

I have to compute stats for each band separately otherwise.

1 Answer 1

4

You can use reduceRegion() method on your image with reducer as ee.Reducer.minMax()

var minMax = dataset.reduceRegion({
    reducer: ee.Reducer.minMax(),
    geometry: roi,
    scale: 30,
    maxPixels: 1e10
})

print('Min & Max all bands: ', minMax)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.