1

I'm exploring different ocean environmental data in Google Earth Engine.

I have created an image per variable by using the .reduce(ee.Reducer.mean()) function.

var sstHS_mean = sstHS_collection.reduce(ee.Reducer.mean());

I have several areas that I'm interested in comparing and have used the .reduceRegions function to reduce into a feature collection to find the mean score for each area I'm interested in.

var sstHS_region = sstHS_mean.reduceRegions({
reducer: ee.Reducer.mean(),
collection: reefsEdit,
scale: 30});

I realised I could combine feature collections and export as a CSV. Using this code.

var sal_sst_HS = ee.FeatureCollection([sstHS_region, salHS_region,]).flatten();

I can then export this as a CSV which produces this table table1

However, it's not clear which data comes from. Is there anyway of adding a label to each image or feature collection so I can identify it when I export the table? Maybe in place of the 0 and 1 seen under system:index or in a new column I could label?

1 Answer 1

3

You can add a property to all the features of each collection that designates where the reduction came from.

Here, I .set() a column name called 'variable' to each feature in both feature collections. For sstHS_region features, I set the variable name as 'sstHS' and for the salHS_region features I set the variable name as 'salHS'.

sstHS_region = sstHS_region.map(function(feature) {
  return feature.set('variable', 'sstHS')
});

salHS_region = salHS_region.map(function(feature) {
  return feature.set('variable', 'salHS')
})

You can also .add(ee.Image.constant(1)).rename('Variable') a band to each of the data images that your are reducing - when you do the reduction the codified variable will be included in the returned feature collection.

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.