I am trying to select type 5 land cover from the MODIS 500m dataset for the year 2001, and then extract out the projection for that layer. However, my script doesn't seem to work because I still obtain a 'collection' when I am expecting an image (since there is 1 dataset per year and I am selecting a specific layer). I know it doesn't work because when i try to extract the projection using projection(), it gives me the error, 'modis.projection is not a function'. I know it works if i put .first for the image collection, but I want to apply this to 2005 as well (and understand where I went wrong).

Another thing I noticed is that the .clip function and .filterBound doesn't seem to work with MODIS (even when I use the .first function. Why is that so?

Thank you in advance.

// Script that doesn't work and gives the error 
var modis = ee.ImageCollection('MODIS/006/MCD12Q1')

print('MODIS projection:', modis.projection());

// Script that works but doesn't end up clipping the image 
var modis = ee.ImageCollection('MODIS/006/MCD12Q1').select('LC_Type5')


Here are a couple of points that I hope clarifies things:

  • filterBounds() must be called on an ee.ImageCollection or ee.FeatureCollection. It filters out images or features from the collection.
  • clip() must be called on an ee.Image. It masks an image.
  • projection() must be called on an ee.Image().
  • Even if you filter your collection down to a single image, with filterDates() or some other filter, you still have an ee.ImageCollection. Calling first() returns you that ee.Image(), which you then can clip or ask for its projection.

Here's your modified script, showing how to pick the first image in a collection and clip it:

var geometry = ee.Geometry.Point([12.49231, 41.89024]).buffer(10000)

var modis = ee.ImageCollection('MODIS/006/MCD12Q1')
  .filterDate('2001-01-01', '2001-12-31')

print('MODIS projection:', modis.projection());


  • Hi Daniel, thank you for taking time out to answer my question. What if I don't want to use the .first() in my script, though, since I am expecting just one image as my output (LC_Type_5 in 2001 and in a specific region? Or is it wrong to assume that my output is only one image in this case, and that I always have to use .first? – catlovingtaco Apr 24 '20 at 8:04
  • You could filter your collection to your area of interest, then do .mosaic() instead of .first(). – Daniel Wiell Apr 24 '20 at 8:34

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.