I tried to set new properties in a map function, but I failed to get these properties outside the map function. The error is:
ComputedObject (Error)
Collection.first: Error in map(ID=0):
Feature.intersection: Parameter 'right' is required.
And the code is:
// double map over the polygons
var mapped = vectors.map(function(feat1){
feat1 = ee.Feature(feat1);
var mapped1 = polygons.map(function(feat2){
feat2 = ee.Feature(feat2);
var intersection = feat2.intersection(feat1, ee.ErrorMargin(1));
return ee.Feature(intersection).set({'Intersect': intersection.area().divide(1000 * 1000),'date':'2016-01-01'})
})
return mapped1
}).flatten().filter(ee.Filter.gt('Intersect', 0));
var test = mapped.first().get('date');
print(test);
As I set new properties "Intersect" and "date", but I cannot get any of them when I print it.
The full code can be found at: https://code.earthengine.google.com/e31d1380d8499df42194fa2a5afa08f1
The test code is written by Rodrigo E. Principe https://gis.stackexchange.com/users/23470/rodrigo-e-principe