0

I'm trying to calculate GPM v6 annual precipitation using the google earth engine. but show this error: Line 11: ee.ImageCollection(...).select(...).filterDate(...).filterBounds(...).clip is not a function

enter image description here

I'm using this code:

Map.addLayer(geometry);
Map.centerObject(geometry);

var ano_inicial = 2000
var ano_final = 2020
var mes = ee.List.sequence(1,12)
var intervalo = ee.List.sequence(ano_inicial,ano_final)
var inicio =  ee.Date.fromYMD(ano_inicial,1,1);
var fim = ee.Date.fromYMD(ano_final,12,31);

var GPM = ee.ImageCollection('NASA/GPM_L3/IMERG_V06')
    .select('IRprecipitation')
    .filterDate(inicio,fim)
    .filterBounds(geometry)
    .clip(geometry);
    
var GPM_Anual = ee.ImageCollection.fromImages(
  intervalo.map(function (ano) {
    var annual = GPM.filter(ee.Filter.calendarRange(ano,ano,'year'))
    .sum()
    .multiply(24*30*12)
    .clip(table)
    return annual
    .set('year',ano)
    .set('system:time_start',ee.Date.fromYMD(ano,1,1))
    }))

Export.image.toDrive({
  image : GPM_Anual,
  description : 'GPM_annual_2000_2020',
  scale : 1000,
  region : geometry,
  maxPixels : 1e9
});

what is wrong?

1
  • Don't clip, you can only clip Images not Image Collections. Either map over the collection and clip everything or just leave it out if it's not completely necessary
    – JonasV
    Sep 10, 2021 at 11:15

1 Answer 1

0

clip is a function you can apply to images only, you are now trying to apply to the entire imageCollection. Instead you need to map over the entire collection (=select individual images) and clip it.

.map(function(img){
      return img.clip(geometry)
    })

https://code.earthengine.google.com/9ad4f0384def03fafe12fc94a3ab5f5d

4
  • I can't run the rest of your script because the variable table is unknown to me. But defintely the approach seems to be allright if you are after the images that contain the summed value for each year.
    – Jobbo90
    Sep 10, 2021 at 11:54
  • when export to google drive show error code.earthengine.google.com/f4a2be718b6bd1dc952e94d59de9cc56
    – waanko
    Sep 10, 2021 at 12:54
  • You can't export an imageCollection with the export.image.toDrive() function. So you have to export each image seperately or use toBands() on the imageCollection to get that done
    – Jobbo90
    Sep 10, 2021 at 13:35
  • I used .toBands() command but I can't export it yet, can you check it? code.earthengine.google.com/dd79cb3fc80ce14275d9bd8af622add7
    – waanko
    Sep 11, 2021 at 4:32

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.