如需仅保存集合中每个元素的第一个匹配项,请使用 ee.Join.saveFirst()
。saveFirst()
联接的运作方式与 saveAll()
联接等效,但对于 primary
集合中的每个元素,它只会保存与 ee.Filter
中指定的条件匹配的 secondary
集合中的第一个元素。primary
集合中的不匹配元素会被舍弃。除非您提供了排序属性和顺序(如 saveAll 示例中所示),否则保存的第一个元素可能是 saveAll()
使用相同过滤条件在列表中找到的任何元素。
先保存联接
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003eee.Join.saveFirst()\u003c/code\u003e is used to save only the first matching element from a secondary collection to each element in a primary collection.\u003c/p\u003e\n"],["\u003cp\u003eIt functions similarly to \u003ccode\u003eee.Join.saveAll()\u003c/code\u003e, but only retains the first match, potentially dropping unmatched primary elements.\u003c/p\u003e\n"],["\u003cp\u003eThe "first" match is arbitrary unless a specific sorting property and order are defined within the join.\u003c/p\u003e\n"]]],[],null,["# Save-First Joins\n\nTo save only the first match for each element in a collection, use an\n`ee.Join.saveFirst()`. The `saveFirst()` join functions in an\nequivalent way to the `saveAll()` join, except for each element in the\n`primary` collection, it simply saves the first element from the\n`secondary` collection matching the condition specified in the\n`ee.Filter`. Unmatched elements in the `primary` collection\nare dropped. Unless a sorting property and an order are supplied (as in the\n[saveAll example](/earth-engine/guides/joins_save_all)), the first element saved might be\nany of the elements in the list found by `saveAll()` with the same filter."]]