I'm trying to filter an image collection using not bands within each image of the collection, but by pattern matching in the image ID. Using:

var dataset_2099 = ee.ImageCollection('NASA/NEX-DCP30')
                  .filter(ee.Filter.date('2099-01-01', '2099-12-31'));

we can create an image collection with forecasted climate data. If I, suppose, want to access just the RCP 2.5 data, I'm in a bind because there doesn't seem to be a clear-cut way to filter the image collection based on individual image names, which begin with "rcpXX" where XX may be 26, 45, 60, or 85 depending on the RCP scenario being mapped.

Image ID's can be printed using the following code, where you can see the pattern that I'm describing:

// Image ID listing code by Tyler Erickson
// https://gis.stackexchange.com/a/281489/67264
// Create a list of image objects.
var imageList = dataset_2099.toList(5000);
print('imageList', imageList);
// Extract the ID of each image object.
var id_list = imageList.map(function(item) {
  return ee.Image(item).id();
print('id_list', id_list);

The problem is I don't just want to get the names of the images, I want to subset the image collection based on those names.

2 Answers 2


Alright, I figured it out. Filtering can be done using the image properties (you can see what properties are available by searching for the product in the search bar). In this case, NASA's NEX-DCP30 data comes with a 'scenario' property, so adding a single line of code filters to this level. For example, to access only the RCP 4.5 projections:

var dataset_2099 = ee.ImageCollection('NASA/NEX-DCP30')
                  .filter(ee.Filter.date('2099-01-01', '2099-12-31'))

Image property-based filtering can be used for specific models in the NEX-DCP30 collection, so users can specify that they just want to look at CSIRO projections using


I had the same question, but in my case the ImageCollection that I wanted to filter was a personal collection. The image ID wasn't included under properties, and so I couldn't use filterMetadata as is. This is probably obvious to many, but thought I may save someone some time by sharing my approach of adding the image id as a property, then filtering by 'contains.'

Many thanks to my references: How to define/add image id in Google Earth Engine? and When adding properties to an image, no longer allowed to add to Map

var ic = NP_AS;
var count = ic.size().getInfo();

var imageList = ic.toList(count);

//setting up a null image collection to add the updated images with properties to
var new_ic = ee.ImageCollection([]);

for (var i = 0; i < count; i++) {        //iterating through the images
  var img = ee.Image(imageList.get(i));  //grab one image at a time
  var id = img.id().getInfo() || 'image_'+i.toString(); //get id, make a string       
  var imgWProp = img.setMulti({
    AOI: "NP",
    product: "isce",
    ID: id                               //set the id as a property of the image 
  // cast it
  imgWProp = ee.Image(imgWProp);
  //add all to a collection, so that it can be filtered
  var new_ic = new_ic.merge(imgWProp);

//filter to only VV images, using ID name
var NP_AS_VV = new_ic.filterMetadata('ID','contains','VV'); 

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .