I am trying to reproject an image collection, but it fails after I apply filtering by (space, time, and cloudy cover percentage)!?

Here is the code:


var S2_f = S2.filterDate('2018-07-03', '2018-07-24')
             .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 5));

Map.addLayer(S2_f, {min: 0,  max:3000, bands: ['B4', 'B3', 'B8A']},'Before Reprojection');

print('projection original', S2_f.projection());

var proj = ee.Projection('EPSG:2062');

print('nominal scale', proj.nominalScale()); 

var S2_r = S2_f.reproject(proj, null, 10);

Map.addLayer(S2_r, {min: 0,  max:3000, bands: ['B4', 'B3', 'B8A']}, 'After Reprojection');

The error message is:

S2_f.projection is not a function



1 Answer 1


You can't reproject an ImageCollection. You can only reproject images. So your code would work like this:

var S2_r = S2_f.first().reproject(proj, null, 10);

If you want to reproject all images in the collection you need to map over the collection and reproject every single Image.

var S2_r = S2_f.map(function(image){
  return image.reproject(proj, null, 10);

However be aware that unless you absolutely need to reproject an Image, it is not advised to do so, since it can add a lot of unnecessary processing overhead. See https://developers.google.com/earth-engine/guides/projections


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.