0

I have 2 timeseries FeatureCollection collected from Landsat looks similar to the following tables.

1st FeatureCollection (fc1):

ID Date prop_1 prop_2
1 2022/10/01 missing in fc2 0.1 0.15
1 2022/10/02 0.2 0.19
2 2022/10/02 0.2 0.3

2nd FeatureCollection (fc2):

ID Date prop_1 prop_2
1 2022/10/02 0.2 0.2
2 2022/10/01 missing in fc1 0.25 0.37
2 2022/10/02 0.2 0.3

I want to join them together into a single FeatureCollection based on feature properties named ID and Date, to keep both matching and non-matching rows.

Final FeatureCollection:

ID Date prop_1 prop_2
1 2022/10/01 0.1 0.15
1 2022/10/02 0.2 0.19
2 2022/10/01 0.25 0.37
2 2022/10/02 0.2 0.3
2
  • Not sure why the table format is not showing properly. Oct 17, 2022 at 3:32
  • I fixed the tables. It seems there needs to be a blank line before each one.
    – Kevin Reid
    Oct 17, 2022 at 3:47

1 Answer 1

-1

Make a composite property out of the two, merge the collections and distinct on the composite property.

function makeKey(f) {
    return f.set('key', f.getString('ID').cat(f.get('date')))
}
c1 = c1.map(makeKey)
c2 = c2.map(makeKey)
var c3 = c1.merge(c2).distinct('key')
1
  • Sorry about the downvote. It was a mitake. Actually, I was trying to save for later. May 5, 2023 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.