0

I am using S1 Imagecollection to start a temporal supervised classification. Firstly, I added polarimetric indexes and other data as bands in each image. Then, I filtered the image collection and got two new ones; one for rainy season and other for dry season.

Now, I am trying to sample each image from the rainy season image collection and get a cumulative sample. This sampling must be done in a drainage area that is already imported as an asset and has a landcover propertie to know the class.

I discovered that it should be done with an iteration, because of the accumulative goal. However, I am new with iterations and I don't get it work.

var bands = ['VV','VH','NDPI','NVVI', 'VHrVV','DOY','DEM','slp'];
var Class0List = ee.List(Class0Images);


function SamplingWater (sample,List) {
  var previous = ee.Image(ee.List(list).get(-1));
  var prevTraining = previous.select(bands).sampleRegions({
  collection: drain, //shape where to sample
  properties: ['landcover'], // Class in the shp as a propertie
  scale: 10 });

  var current = sample.select(bands).sampleRegions({
  collection: drain, //shape where to sample
  properties: ['landcover'], // Class in the shp as a propertie
  scale: 10 });

  return current.merge(prevTraining);  // merging current and previous sample
}


// mapping function through near saturation image collection
var WSample = Class0Images.iterate(SamplingWater,Class0List);
print(WSample);

You can find the complete code in the following link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.