Earth Engine 資產是儲存在平台中的專案自有地理空間資料。您可以上傳自己的資料,以及將 Earth Engine 分析產生的資料儲存為資產。
資產類型
Earth Engine 提供各種資產格式,適用於不同資料類型,並提供用於整理資料的容器元素。
| 資產類型 | |
|---|---|
Image |
點陣圖,以格線為基礎的地理資訊表示法,格線中的每個儲存格都包含對應地球表面特定位置的值。 |
ImageCollection |
相關點陣圖像的集合,構成鑲嵌或時間序列。這項功能與資料夾類似,但可以匯入 Earth Engine 做為 ee.ImageCollection 物件,其中包含一組用於篩選和分析的方法。 |
Table |
由向量特徵 (資料列) 組成的資料表資料結構,每個向量特徵都包含一系列屬性 (資料欄)。這類資料以 ee.FeatureCollection 物件表示,內含一組用於篩選和分析的方法。 |
Classifier |
訓練完成的 Earth Engine 機器學習模型。這項功能由 ee.Classifier |
FeatureView |
表格的視覺化檢視畫面,可用於 Earth Engine 應用程式。 |
Folder |
素材資源和額外資料夾的容器,有助於整理內容。 |
素材資源整理
Earth Engine 資產會整理成資料夾和集合的階層式系統。結構與一般檔案系統類似。
根層級
資產由 Cloud 專案擁有。專案名稱會定義資產目錄的根目錄。舉例來說,my-project 的根是 projects/my-project/assets。屬於 my-project 的所有素材資源都位於 projects/my-project/assets 資料夾或其中的子資料夾 (或 ImageCollection)。
目錄
Earth Engine 會使用樹狀目錄結構來整理資產。每個雲端專案都有根目錄,可包含個別資產和資料夾。ImageCollection 是一種特殊資產類型,專門用於保存相關圖片集,例如時間序列或鑲嵌圖片。與資料夾不同,ImageCollection 只能包含圖片素材資源,且無法在其中巢狀內嵌其他資料夾或集合。
- folder_dataprojects/my-project/assets/
- folder folder-name/
- photo image-name
- view_comfy table-name
- satellite featureview-name
- bubble_chart 分類器名稱
- photo_library imagecollection-name/
- photo image-name-1
- photo image-name-2
資產 ID
Earth Engine 會使用資產 ID 參照指令碼和指令列作業中的資料。這些路徑會使用正斜線 (/) 做為目錄間的分隔符號,定義資產位置。舉例來說,
projects/my-project/assets/my-asset 指定位於「my-project」根目錄中名為「my-asset」的資產。以下是使用這個 ID 取得資產資訊的範例。
Python
print(ee.data.getAsset('projects/my-project/assets/my-asset'))
程式碼編輯器
print(ee.Image('projects/my-project/assets/my-asset'))
指令列
earthengine asset info projects/my-project/assets/my-asset建立素材資源
您可以建立資料夾和 ImageCollection,並從本機檔案或 Google Cloud Storage 值區中的檔案擷取圖片和表格。支援的圖片格式包括 GeoTIFF (標準和 COG) 和 TFRecord。支援的表格格式包括 Shapefile 和 CSV。(您也可以使用批次函式 Export.*.toAsset,匯出 Earth Engine 分析結果來建立資產)。
Python 用戶端
圖片
使用 ee.data.startIngestion
函式從 Cloud Storage 擷取圖片。如要進一步瞭解如何設定上傳作業,請參閱圖片資訊清單頁面。
manifest = {
'name': 'projects/my-project/assets/asset-name',
'tilesets': [
{
'sources': [
{
'uris': [
'gs://my-bucket/filename.tif'
]
}
]
}
]
}
ee.data.startIngestion(None, manifest)
資料表
使用 ee.data.startTableIngestion 函式從 Cloud Storage 擷取資料表。如要進一步瞭解如何設定上傳作業,請參閱圖片資訊清單頁面。
manifest = {
'name': 'projects/my-project/assets/asset-name',
'sources': [
{
'uris': [
'gs://my-bucket/filename.csv'
]
}
]
}
ee.data.startTableIngestion(None, manifest)
資料夾或 ImageCollection
使用 ee.data.createAsset 函式建立空白資料夾或 ImageCollection。
ee.data.createAsset(
{'type': 'FOLDER'}, # or 'IMAGE_COLLECTION'
'projects/my-project/assets/asset-name'
)
程式碼編輯器
在素材資源管理工具中,按一下「新增」按鈕,然後從下拉式清單中選取要上傳或建立的素材資源類型。在對話方塊中設定素材資源上傳或建立作業。
指令列
圖片或表格
earthengine upload image --asset_id=projects/my-project/assets/asset-name gs://my-bucket/filename.tifearthengine upload table --asset_id=projects/my-project/assets/asset-name gs://my-bucket/filename.csv
資料夾或 ImageCollection
使用 earthengine create 指令建立空白資料夾或 ImageCollection。
earthengine create folder projects/my-project/assets/folder-nameearthengine create collection projects/my-project/assets/collection-name
外部圖片
上傳至 Google Cloud Storage bucket 的雲端最佳化 GeoTIFF (COG) 檔案可註冊為外部圖像資產,並直接在 Earth Engine 中使用。如要進一步瞭解 COG 支援的資產和建構資訊清單,請參閱參考文件。
earthengine alpha upload external_image --manifest /tmp/foo.json列出資產
Python 用戶端
使用 ee.data.listAssets 函式列出資料夾或集合中的資產 (非遞迴)。如要進一步瞭解篩選和分頁功能,請參閱參考文件。
ee.data.listAssets('projects/my-project/assets')
程式碼編輯器
展開素材資源管理工具中的資料夾,即可查看素材資源。
指令列
使用 earthengine ls 指令列出資料夾或集合中的資產 (非遞迴)。如要進一步瞭解如何限制要列出的資產數量和要傳回的金額詳細資料,請參閱參考文件。
earthengine ls projects/my-project/assets設定資產權限
Python 用戶端
使用 ee.data.setAssetAcl 函式設定資產的權限。
asset_id = 'projects/my-project/assets/asset-name'
acl_update = {
'owners': [
'user:big_cheese@example.com',
'user:el_jefe@example.com'
],
'writers': [
'user:romeo@example.com',
'user:juliet@example.com'
],
'readers': [
'group:some-group@googlegroups.com',
'domain:example.com',
'serviceAccount:some-project-id@appspot.gserviceaccount.com'
],
'all_users_can_read': False
}
ee.data.setAssetAcl(asset_id, acl_update)
程式碼編輯器
在資產管理工具中,將游標懸停在資產上,然後按一下「分享」圖示。在對話方塊中,輸入要分享資產的電子郵件地址或網域,然後從下拉式清單中選取要授予的權限層級。按一下「新增存取權」按鈕,確認變更。勾選「任何人都能讀取」方塊,即可授予任何實體讀取權限。您也可以從對話方塊的下拉式清單中選取應用程式名稱 (有效程式碼編輯器專案擁有的資產),授予 Earth Engine 應用程式的存取權。
指令列
使用 earthengine acl set 指令將資產的讀取權設為 public 或 private。
earthengine acl set public projects/my-project/assets/asset-name使用 earthengine acl ch 指令設定資產讀取和寫入的個別權限。
earthengine acl ch -u person@gmail.com:R projects/my-project/assets/asset-name詳情請參閱指令列參考資料頁面。
檢查資產權限
Python 用戶端
使用 ee.data.getAssetAcl 函式擷取資產的存取控制清單。
ee.data.getAssetAcl('projects/my-project/assets/asset-name')
程式碼編輯器
在資產管理工具中,將游標懸停在資產上,然後按一下「分享」圖示。對話方塊會顯示電子郵件和網域清單,以及各自的存取層級。
指令列
使用 earthengine acl get 指令擷取資產的存取權控制清單。
earthengine acl get projects/my-project/assets/asset-name複製資產
Python 用戶端
使用 ee.data.copyAsset 函式複製資產。
ee.data.copyAsset('projects/my-project/assets/asset-name', 'projects/my-project/assets/asset-copy-name')
程式碼編輯器
使用 Python 用戶端或指令列工具複製資產。
指令列
使用 earthengine cp 指令複製資產。
earthengine cp projects/my-project/assets/asset-name projects/my-project/assets/asset-copy-name移動或重新命名素材資源
Python 用戶端
使用 ee.data.renameAsset 函式移動或重新命名資產。
ee.data.renameAsset('projects/my-project/assets/asset-name', 'projects/my-project/assets/new-asset-name')
程式碼編輯器
移動
在素材資源管理工具中,將素材資源拖曳到新資料夾。
重新命名
在資產管理工具中,將指標懸停在資產上,然後按一下「編輯」圖示,並在可編輯的輸入欄位中輸入新名稱。
指令列
使用 earthengine mv 指令移動或重新命名資產。
earthengine mv projects/my-project/assets/asset-name projects/my-project/assets/new-asset-name刪除資產
Python 用戶端
使用 ee.data.deleteAsset 函式刪除資產。
ee.data.deleteAsset('projects/my-project/assets/asset-name')
程式碼編輯器
指令列
使用 earthengine rm 指令刪除資產。如需遞迴和試執行選項,請參閱函式參考資料。
earthengine rm projects/my-project/assets/asset-name查看資產中繼資料
Python 用戶端
使用 ee.data.getAsset 函式取得資產中繼資料。
ee.data.getAsset('projects/my-project/assets/asset-name')
程式碼編輯器
按一下資產,開啟資產對話方塊頁面。查看資產資訊。
指令列
使用 earthengine asset info 指令取得資產中繼資料。
earthengine asset info projects/my-project/assets/asset-name設定資產中繼資料
可設定的資產中繼資料如下:
start_timeend_timeproperties
Python 用戶端
使用 ee.data.updateAsset 函式更新資產中繼資料。
asset_id = 'projects/my-project/assets/asset-name'
new_metadata = {
'properties': {
'name': 'value'
},
'start_time': '2024-10-02T15:01:24Z',
'end_time': '2024-10-02T15:01:25Z',
}
update_these = ['start_time', 'end_time', 'properties']
ee.data.updateAsset(asset_id, new_metadata, update_these)
程式碼編輯器
按一下素材資源開啟素材資源對話方塊頁面,然後啟用右上方的編輯切換按鈕。你可以編輯說明、屬性、開始和結束日期。停用編輯切換鈕即可儲存變更。
指令列
使用 earthengine asset set 指令更新資產中繼資料。詳情請參閱參考文件。
earthengine asset set \
--time_start 2024-10-02T15:01:24 \
--time_end 2024-10-02T15:01:25 \
--property 'name=value' \
projects/my-project/assets/asset-name
檢查資產配額
配額適用於專案層級。如要進一步瞭解資產配額,請前往「用量和配額限制」頁面。
Python 用戶端
使用 ee.data.getAssetRootQuota 函式取得資產根目錄的儲存空間配額用量。
ee.data.getAssetRootQuota('projects/my-project/assets')
程式碼編輯器
在資產管理工具中,將指標懸停在專案根目錄上,然後按一下 data_usage 圖示。系統會顯示資訊對話方塊。
指令列
使用 Python 用戶端或程式碼編輯器檢查資產配額。