公告:凡是在
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 和專案,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) |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間: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) |"]]