1

I want to read the minimum and maximum rainfall value for my study region. While using the reducer function I can read the mean value, however, for min and max value it is showing null. I wish to extract the min and max value to control the color bar/ palette limit. How to read the min and max values. Below is my script,

Map.addLayer(Tawi, visParams, nameLayer, shown, opacity); /Tawi is the name of shapefile
Map.centerObject(Tawi);

var ChirpsDataset = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY');
var Chirps = ChirpsDataset.filterDate('2018-07-14', '2019-07-30').sum().clip(Tawi);
                     
print(Chirps, 'Precipitation');
var precip = Chirps.select('precipitation');

var meanValue = Chirps.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: Tawi.geometry(),
  crs: 'EPSG:4326',
  crsTransform: [1,0,0,0,1,0],
  maxPixels: 1e9
});    
print('Mean precipitation:', meanValue)

var maxValue = Chirps.reduceRegion({
  reducer: ee.Reducer.max(),
  geometry: Tawi.geometry(),
  crs: 'EPSG:4326',
  crsTransform: [1,0,0,0,1,0],
  maxPixels: 1e9
});    
print('Max precipitation:', maxValue)

Here is the link to script.

2

1 Answer 1

2

You'd probably best define an appropriate scale for your analysis. Read about scale here. The composite image of you has crsTransform: [1,0,0,0,1,0], which gives a scale of 111319m:

print(precip.projection().nominalScale())

Probably, you want to run the computation on the scale of the imagery. It depends on where you are on the world, but approx 5km should fit well for your area. Thus, a better idea would be defining the scale (in meters), for example:

var maxValue = Chirps.reduceRegion({
  reducer: ee.Reducer.max(),
  geometry: Tawi.geometry(),
  scale: 5000,
  maxPixels: 1e9
});    
print('Max precipitation:', maxValue)
1
  • It worked, however, I have one more query, is their any way to read that scale of 5000 m from the image itself. This would be better as different images will have different scale e.g., Landsat or Sentinel.
    – dsbisht
    Jul 3, 2020 at 11:46

Your Answer

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

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