公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Date.aside
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
调用一个函数,将此对象作为第一个实参传递,并返回自身。方便(例如,在调试时):
var c = ee.ImageCollection('foo').aside(print)
.filterDate('2001-01-01', '2002-01-01').aside(print, 'In 2001')
.filterBounds(geom).aside(print, 'In region')
.aside(Map.addLayer, {min: 0, max: 142}, 'Filtered')
.select('a', 'b');
返回同一对象,用于链式调用。
用法 | 返回 |
---|
Date.aside(func, var_args) | ComputedObject |
参数 | 类型 | 详细信息 |
---|
此:computedobject | ComputedObject | ComputedObject 实例。 |
func | 函数 | 要调用的函数。 |
var_args | VarArgs<Object> | 要传递给函数的任何额外实参。 |
示例
代码编辑器 (JavaScript)
// Print a message when constructing the ee.Date.
var eeDict = ee.Date(Date.now()).aside(print, "Today's date (UTC)");
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
from datetime import datetime
def print_date(ee_date, message):
"""Prints a formatted date, along with a descriptive message."""
display(message, ee_date.format("YYYY-mm-dd"))
# Print a message when constructing the ee.Date.
ee_date = ee.Date(datetime.now()).aside(print_date, "Today's date (UTC):")
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003easide()\u003c/code\u003e allows you to call a function on a ComputedObject (like an ImageCollection or Date) for debugging or visualization without interrupting the chain of operations.\u003c/p\u003e\n"],["\u003cp\u003eIt passes the ComputedObject as the first argument to the provided function, along with any additional arguments you specify.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003easide()\u003c/code\u003e returns the original ComputedObject, making it seamless to integrate into existing workflows.\u003c/p\u003e\n"],["\u003cp\u003eThe function you provide to \u003ccode\u003easide()\u003c/code\u003e can be anything, from \u003ccode\u003eprint()\u003c/code\u003e for debugging to \u003ccode\u003eMap.addLayer()\u003c/code\u003e for visualization.\u003c/p\u003e\n"],["\u003cp\u003eThis method facilitates understanding intermediate steps and inspecting results within a sequence of Earth Engine operations.\u003c/p\u003e\n"]]],["The `aside` function, applicable to `ComputedObject` instances, executes a provided function (`func`) with the object as the first argument, alongside any additional arguments (`var_args`). It returns the original object, enabling method chaining. This is useful for debugging or applying side effects, such as printing values or adding layers to a map during data processing. Examples show its use with `ee.Date` and `ee.ImageCollection` in both JavaScript and Python environments.\n"],null,["# ee.Date.aside\n\n\u003cbr /\u003e\n\nCalls a function passing this object as the first argument, and returning itself. Convenient e.g. when debugging:\n\n\u003cbr /\u003e\n\nvar c = ee.ImageCollection('foo').aside(print)\n\n.filterDate('2001-01-01', '2002-01-01').aside(print, 'In 2001')\n\n.filterBounds(geom).aside(print, 'In region')\n\n.aside(Map.addLayer, {min: 0, max: 142}, 'Filtered')\n\n.select('a', 'b');\n\nReturns the same object, for chaining.\n\n| Usage | Returns |\n|------------------------------|----------------|\n| Date.aside`(func, var_args)` | ComputedObject |\n\n| Argument | Type | Details |\n|------------------------|-------------------|----------------------------------------------|\n| this: `computedobject` | ComputedObject | The ComputedObject instance. |\n| `func` | Function | The function to call. |\n| `var_args` | VarArgs\\\u003cObject\\\u003e | Any extra arguments to pass to the function. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Print a message when constructing the ee.Date.\nvar eeDict = ee.Date(Date.now()).aside(print, \"Today's date (UTC)\");\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nfrom datetime import datetime\n\ndef print_date(ee_date, message):\n \"\"\"Prints a formatted date, along with a descriptive message.\"\"\"\n display(message, ee_date.format(\"YYYY-mm-dd\"))\n\n# Print a message when constructing the ee.Date.\nee_date = ee.Date(datetime.now()).aside(print_date, \"Today's date (UTC):\")\n```"]]