Geographic Information Systems Asked on March 28, 2021
I have two feature collections, produced using the reduceRegions function, from different image collections. I can export both as CSV, but I’ve been trying to join or merge them so I can export them as one single CSV. I just need one column from one feature collection to be added to the other.
I’ve tried to use the ee.Join.saveAll for this. But it doesn’t come out quite right. It joins the feature collections but adds the secondary featureCollection as a single column, so I can’t see the data when i export as a CSV. Only one column differs in the second feature collection, and I’d like to add that to the first.
// Use an equals filter to define how the collections match.
var filter = ee.Filter.equals({
leftField: 'system:index',
rightField: 'system:index',
});
// Define the join.
var saveAllJoin = ee.Join.saveAll({
matchesKey: 'mean',
ordering: 'system:time_start',
ascending: true
});
// Apply the join.
var Dat = saveAllJoin.apply(HS_allVars, allVars, filter);
// Display the result.
print('Dat', Dat);
Export.table.toDrive({
collection: Dat,
description: 'Dat',
fileFormat: 'CSV'
});
Here is a link to the full code. The lines I’m having issues with are 918-944.
https://code.earthengine.google.com/ae7576ddf2abbc6ee219a7bd4a87b1d2
I think you mean that you want the mean attribute of the "joined" feature to be a property of the parent feature, right?
var DatFlat = Dat.map(function(mainFeature){
var joinedFeaturesList = ee.List(mainFeature.get('mean'))
return mainFeature.set('mean', ee.Feature(joinedFeaturesList.get(0)).get('mean'));
});
print('DatFlat', DatFlat)
Answered by Jonas on March 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP