1

I want to get the precipitation totals for certain months, but when I run it on the WorldClim Climatology V1 dataset, I get the following error message. how can i fix this?

Error message:

Precipitation: Layer error: Image.select: Pattern 'prec' did not match any bands.

Here is the link: https://code.earthengine.google.com/6cb56709133460613b28eadd98992e6a

var dataset = ee.ImageCollection('WORLDCLIM/V1/MONTHLY')
                  .filter(ee.Filter.calendarRange(2013,2021,'year'))
                  .filter(ee.Filter.calendarRange(5,10,'month'))
                  .sum() ;
var precipitation = dataset.select('prec');
var precipitationVis = {
  min: 0.0,
  max: 200.0,
  palette: ['001137', '0aab1e', 'e7eb05', 'ff4a2d', 'e90000'],
};
Map.setCenter(17.93, 7.71, 2);
Map.addLayer(precipitation, precipitationVis, 'Precipitation');


Export.image.toDrive({
image: precipitation.int(),
description: "Annualrainfall_",
region: antalya,
maxPixels: 1e13,
});

print(dataset);

1 Answer 1

1

That ImageCollection doesn't have a timestamp so you can't filter by calendarRange. Therefore, when you filtered by calendarRange, an empty ImageCollection was returned, which caused the error. This is because there are no Images in the empty collection, hence no bands named "prec".

Notes:

  • The images represent averages for the period 1960-01-01 - 1991-01-01 so your requested date range is not available.
  • There are only 12 images in the collection, one for each month, and the values are averages for that month for the entire period. Not the average for a specific month in a specific year in that period.

To access each month:

var dataset = ee.ImageCollection('WORLDCLIM/V1/MONTHLY')
    .filter(ee.Filter.inList('month', ee.List([5,6,7,8,9,10])));
var precipitation = dataset.select('prec').sum();

Or

var dataset = ee.ImageCollection('WORLDCLIM/V1/MONTHLY')
    .filter(ee.Filter.gte('month', 5))
    .filter(ee.Filter.lte('month', 10));
var precipitation = dataset.select('prec').sum();

Or even just select the images directly:

var dataset = ee.ImageCollection([
  ee.Image('WORLDCLIM/V1/MONTHLY/05'),
  ee.Image('WORLDCLIM/V1/MONTHLY/06'),
  ee.Image('WORLDCLIM/V1/MONTHLY/07'),
  ee.Image('WORLDCLIM/V1/MONTHLY/08'),
  ee.Image('WORLDCLIM/V1/MONTHLY/09'),
  ee.Image('WORLDCLIM/V1/MONTHLY/10'),
  ]);
var precipitation = dataset.select('prec').sum();
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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