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



//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

//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');


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


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.