0

This code works well until the last two blocks. The second to last block multiplies all raster pixel values in an image collection by 10. The last block is supposed to parse the entire collection into separate collections by year. What currently happens is that the image collection seems to work for everything but the last block. When I try to put SAR100 into the parsing block, it returns zero rasters band for each year when there should definitely be more. I receive no error messages when running the code. I will include a GEE link for this code. The study area, named "geometry", is an arbitrary small polygon.

//Changeable Parameters
var startYear = '2016';
var startDate = '-04-01';
var endYear = '2018';
var endDate = '-09-30';
var polarization = 'VH';
var studyRegion = geometry; 

//--------------------------------------------------------------------
//          Modify Sentinel-1 collection to desired specifications  
//--------------------------------------------------------------------

//Select image collection, filter it to desired polarization,
  //instrument mode, overall start/end dates, and orbital direction
var imgVV = ee.ImageCollection('COPERNICUS/S1_GRD')
        .filter(ee.Filter.listContains('transmitterReceiverPolarisation', polarization))
        .filter(ee.Filter.eq('instrumentMode', 'IW'))
        .select(polarization)
        .filterBounds(studyRegion)
        .filterDate( '2017-01-01', '2020-12-31')
        .filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING'));
        

//Clip image collection to study area polygon        
var clippedSAR = imgVV.map(function(image) { return image.clip(studyRegion); });
print(clippedSAR, 'clippedSAR');

//--------------------------------------------------------------------
//          Multiply collection by 10
//--------------------------------------------------------------------

var SAR100 = clippedSAR.map(function(image) { 
  return image.multiply(10); 
});
print(SAR100, 'SAR100');

//--------------------------------------------------------------------
//          Parse complete collection into separate years  
//--------------------------------------------------------------------

var collections = {};
for (var year = startYear; year <= endYear; year++) 
  collections[year] = SAR100.filterDate(year.toString() 
  + startDate, year.toString() + endDate).filterBounds(studyRegion);
print ('collections', collections);

https://code.earthengine.google.com/7f906f531ca5ab8aad20ff2dc3cf41c8

1 Answer 1

2

.multiply() does not preserve image properties.

image.multiply(10) is equivalent to multiplying image by ee.Image.constant(10). ee.Image.constant(10) has no properties and hence you lose all properties (including system:time_start and system:time_end which are required for your date filter to work).

So while multiplying, just copy back the new properties like this

image.multiply(10).copyProperties(image, image.propertyNames()); 

Link to fixed code.

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.