ee.initialize
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เริ่มต้นใช้งานไลบรารี หากยังไม่ได้เรียกใช้ฟังก์ชันนี้เมื่อมีการใช้ตัวสร้างออบเจ็กต์ ระบบจะเรียกใช้ฟังก์ชันนี้ในตอนนั้น หากมีการเรียกใช้ฟังก์ชันนี้เป็นครั้งที่ 2 โดยมี 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 | สตริง ไม่บังคับ | ปลายทาง REST API ของ Earth Engine
(ชื่ออาร์กิวเมนต์ Python: opt_url) |
tileurl | สตริง ไม่บังคับ | ปลายทางไทล์ REST ของ Earth Engine ซึ่งเป็นค่าที่ไม่บังคับและมีค่าเริ่มต้นเป็น baseurl (JavaScript เท่านั้น) |
successCallback | ฟังก์ชัน (ไม่บังคับ) | Callback ที่ไม่บังคับซึ่งจะเรียกใช้เมื่อการเริ่มต้นสำเร็จ หากไม่ได้ระบุไว้ ระบบจะเริ่มต้นใช้งานแบบพร้อมกัน (JavaScript เท่านั้น) |
errorCallback | ฟังก์ชัน (ไม่บังคับ) | การเรียกกลับที่ไม่บังคับซึ่งจะเรียกใช้พร้อมข้อผิดพลาดหากการเริ่มต้นไม่สำเร็จ (JavaScript เท่านั้น) |
xsrfToken | สตริง ไม่บังคับ | สตริงที่จะส่งในพารามิเตอร์ "xsrfToken" ของ XHR ของ EE API (JavaScript เท่านั้น) |
project | สตริง ไม่บังคับ | รหัสหรือหมายเลขโปรเจ็กต์ไคลเอ็นต์ที่ไม่บังคับที่จะใช้เมื่อทำการเรียก API (ชื่ออาร์กิวเมนต์ Python: project) |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\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) |"]]