# How to find the minimum and maximum value of a region and give these values to the visualisation parameters in Google Earth Engine?

What I mean is: We are giving the min and max value to the visualization parameters but in my case min and max value changes according to geometry so how can i find the min and max value and give these values to the visualization parameters.

My code is:

``````var median = coll.reduce(ee.Reducer.median()).clip(geometry);

var extrema = median.select('CO_column_number_density_median').reduceRegion(ee.Reducer.minMax(),geometry,250);

var min1 = extrema.getNumber('CO_column_number_density_median_min');

var max1 = extrema.getNumber('CO_column_number_density_median_max');

var visParams={
min:min1,
max:max1,
opacity: 1.0,
palette: ["blue","green","red","cyan","black","yellow","purple"],
bands:['CO_column_number_density_median']
};

``````

I will find the solution but this method is very slow. so if anybody found another solution then please tell me the solution.

soluton:

``````var median = coll.reduce(ee.Reducer.median()).clip(geometry);
var Extrema=median.select('CO_column_number_density_median').reduceRegion(ee.Reducer.minMax(),geometry,250)

var min1=(Extrema.getNumber('CO_column_number_density_median_min')).getInfo();
var max1=(Extrema.getNumber('CO_column_number_density_median_max')).getInfo();

var visParams={
min:min1,
max: max1,
opacity: 1.0,
palette: ["blue","green","red","yellow","black","cyan","purple"],
bands:['CO_column_number_density_median']
};