0

I am attempting to clip an ImageCollection in GEE, but I keep getting the error

"Unable to transform edge (43200.000000, 1.476288 to 43200.000000, 1.477361) from SR-ORG:6974 PLANAR [926.625433055833, 0.0, -2.0015109354E7, 0.0, -926.6254330558334, 1.0007554677003E7] to EPSG:4326."

Below is my code that I am working with. The main function (evi) obtains the necessary images and returns a list of images, each with a number of bands. The list is then cast to an ImageCollection, which I then try to clip using the last function (us_clip). The clip returns the error noted above. In testing, when I use us_clip on an ImageCollection that hasn't been through the evi function below, it is successful.

Can you provide some guidance on clipping the resulting ImageCollection?

var geompoly = ee.Geometry.Polygon(
        [[[-130.2328, 52.851],
          [-63.6722, 52.851],
          [-63.6722, 21.7423],
          [-130.2328, 21.7423]]], null, false);
          
var myList = ee.List.sequence(1,12);                       //months

function evi(month){
  //get mask images
  var modis_mask = ee.ImageCollection('MODIS/061/MOD13A2') //modis terra 16-day mask
  .select('SummaryQA')                                     //select mask band
  .filter(ee.Filter.calendarRange(2009,2018,'year'))       //filter for years 2009-2018
  .filter(ee.Filter.calendarRange(month, month, 'month'))  //filter on month
  .toBands()                                               //imgcoll -> image
  .eq(0);                                                  //0 = Good data, Use with confidence
  
  //get evi images
  var modis_evi = ee.ImageCollection('MODIS/061/MOD13A2') //modis terra 16-day evi
  .select('EVI')                                          //select evi band
  .filter(ee.Filter.calendarRange(2009,2018,'year'))      //filter for years 2009-2018
  .filter(ee.Filter.calendarRange(month, month, 'month')) //filter on month
  .toBands()                                              //imgcoll -> image
  .updateMask(modis_mask);                                //mask lesser quality pixels
  
  var bands = modis_evi.bandNames();                      //get band names
  
  //function to go from image w/ bands -> list of images
  function bands2imglst(bandnames) {
  return modis_evi.select([bandnames]);
  }
  var list = bands.map(bands2imglst);                     //create list of images

  var collection = ee.ImageCollection.fromImages(list)    //list of images -> imgcoll
    .toBands();                                           //imgcoll -> img w/ bands
 
  return(collection);
}

//execute function
var modis_evi_result = myList.map(evi);                    //returns list of images w/ bands

var modis_evi_coll = ee.ImageCollection(modis_evi_result); //list -> image collection
print(modis_evi_coll);

//funtion to clip images w/in imgcoll
function us_clip(imgcol) {
  var manip_img = imgcol.clip(geompoly);
  return manip_img;
}  
var clipped = modis_evi_coll.map(us_clip);
print(clipped);```

1 Answer 1

1

Seems to be a bug, but you can work around it by clipping the individual images before you call toBands:

  var modis_evi = ee.ImageCollection('MODIS/061/MOD13A2')
    .select('EVI')
    .filter(ee.Filter.calendarRange(2009,2018,'year'))
    .filter(ee.Filter.calendarRange(month, month, 'month'))
    .map(function(img) {
      return img.clip(geompoly)
    })
    .toBands()
    .updateMask(modis_mask)

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.