公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.initialize
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
初始化库。如果在任何对象构造函数使用之前未调用此方法,则会在那时调用此方法。如果使用不同的 baseurl 或 tileurl 第二次调用此方法,则不会取消初始化之前加载的算法等,但会覆盖它们并指向备用服务器。
如果首次在异步模式下调用 initialize()(通过传递成功回调),则任何未来的异步模式调用都会将其回调添加到队列中,并且所有回调都会一起运行。
如果在任意数量的异步调用之后进行同步模式调用,则该调用会先阻塞并执行之前提供的所有回调,然后再返回。
在大多数情况下,应在初始化库之前设置授权令牌,方法是使用 ee.data.authorize() 或 ee.data.setAuthToken()。
在 Python 中,此方法名为 ee.Initialize,其中 I 为大写。请注意,部分参数在 JavaScript 和 Python 之间有所不同。除了下面的 opt_url 和 project 之外,Python 还支持:credentials - 一个 google.oauth2.Credentials 对象或“persistent”,用于使用存储的凭据(默认);http_transport - 一个 httplib2.Http 客户端。
用法 | 返回 |
---|
ee.initialize(baseurl, tileurl, successCallback, errorCallback, xsrfToken, project) | |
参数 | 类型 | 详细信息 |
---|
baseurl | 字符串,可选 | Earth Engine REST API 端点。
(Python 实参名称:opt_url) |
tileurl | 字符串,可选 | Earth Engine REST 图块端点,此参数为可选参数,默认值为 baseurl。(仅限 JavaScript) |
successCallback | 函数(可选) | 初始化成功时要调用的可选回调。如果未提供,则初始化会同步完成。(仅限 JavaScript) |
errorCallback | 函数(可选) | 如果初始化失败,则使用错误调用的可选回调。(仅限 JavaScript) |
xsrfToken | 字符串,可选 | 要传递给 EE API XHR 的“xsrfToken”参数的字符串。(仅限 JavaScript) |
project | 字符串,可选 | 进行 API 调用时要使用的可选客户端项目 ID 或编号。(Python 实参名称:project) |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe \u003ccode\u003eee.initialize()\u003c/code\u003e function initializes the Earth Engine library, setting the API endpoint and optional tile server.\u003c/p\u003e\n"],["\u003cp\u003eInitialization can be performed synchronously or asynchronously with success and error callbacks.\u003c/p\u003e\n"],["\u003cp\u003eAuthorization should typically be handled before initialization using \u003ccode\u003eee.data.authorize()\u003c/code\u003e or \u003ccode\u003eee.data.setAuthToken()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eee.initialize()\u003c/code\u003e offers parameters for customization, like base URL, tile URL, and project ID.\u003c/p\u003e\n"],["\u003cp\u003eThe Python equivalent is \u003ccode\u003eee.Initialize()\u003c/code\u003e, with minor parameter differences compared to JavaScript.\u003c/p\u003e\n"]]],[],null,["# ee.initialize\n\n\u003cbr /\u003e\n\nInitialize the library. If this hasn't been called by the time any object constructor is used, it will be called then. If this is called a second time with a different baseurl or tileurl, this doesn't do an un-initialization of e.g.: the previously loaded Algorithms, but will overwrite them and let point at alternate servers.\n\n\u003cbr /\u003e\n\nIf initialize() is first called in asynchronous mode (by passing a success callback), any future asynchronous mode calls will add their callbacks to a queue and all the callbacks will be run together.\n\nIf a synchronous mode call is made after any number of asynchronous calls, it will block and execute all the previously supplied callbacks before returning.\n\nIn most cases, an authorization token should be set before the library is initialized, either with ee.data.authorize() or ee.data.setAuthToken().\n\nIn Python, this method is named ee.Initialize, with a capital I. Note that some parameters differ between JavaScript and Python. In addition to opt_url and project below, Python also supports: credentials - a google.oauth2.Credentials object or 'persistent' to use stored credentials (the default); http_transport - a httplib2.Http client.\n\n| Usage | Returns |\n|--------------------------------------------------------------------------------------------------------------------|---------|\n| `ee.initialize(`*baseurl* `, `*tileurl* `, `*successCallback* `, `*errorCallback* `, `*xsrfToken* `, `*project*`)` | |\n\n| Argument | Type | Details |\n|-------------------|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `baseurl` | String, optional | The Earth Engine REST API endpoint. (Python argument name: opt_url) |\n| `tileurl` | String, optional | The Earth Engine REST tile endpoint, this is optional and defaults to baseurl. (JavaScript only) |\n| `successCallback` | Function, optional | An optional callback to be invoked when the initialization is successful. If not provided, the initialization is done synchronously. (JavaScript only) |\n| `errorCallback` | Function, optional | An optional callback to be invoked with an error if the initialization fails. (JavaScript only) |\n| `xsrfToken` | String, optional | A string to pass in the \"xsrfToken\" parameter of EE API XHRs. (JavaScript only) |\n| `project` | String, optional | Optional client project ID or number to use when making API calls. (Python argument name: project) |"]]