管理資產

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 會使用樹狀目錄結構來整理資產。每個 Cloud 專案都有一個根目錄,可包含個別資產和資料夾。ImageCollections 是一種特殊的素材資源類型,專門用於保留相關圖片的組合,例如時序或馬賽克。與資料夾不同,ImageCollections 只能包含圖片素材資源,且無法在其中巢狀其他資料夾或集合。

  • folder_dataprojects/my-project/assets/
    • 資料夾 資料夾名稱/
      • photo image-name
      • view_comfy 資料表名稱
      • satellite featureview-name
      • bubble_chart 分類器名稱
      • photo_library imagecollection-name/
        • 相片 image-name-1
        • 相片 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 函式建立空白資料夾或 ImageCollections。

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.tif
earthengine 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-name
earthengine create collection projects/my-project/assets/collection-name

外部圖片

上傳至 Google Cloud Storage 值區的雲端最佳化 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')

另請參閱 ee.data.listImagesee.data.listFeatures

程式碼編輯器

展開素材資源管理工具中的資料夾即可查看素材資源。

指令列

使用 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)

程式碼編輯器

在素材資源管理工具中,將游標懸停在素材資源上,然後點選「分享」圖示。在對話方塊中輸入要分享素材資源的電子郵件地址或網域,然後從下拉式清單中選取要授予的權限層級。按一下「新增存取權」按鈕,確認變更。勾選「任何人都可以讀取」方塊,即可授予任何實體讀取權限。您也可以從對話方塊中選取應用程式名稱 (由使用中的 Code Editor 專案擁有的資產),藉此提供 Earth Engine 應用程式的存取權。

指令列

使用 earthengine acl set 指令,將資產的讀取權限設為 publicprivate

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_time
  • end_time
  • properties

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')

程式碼編輯器

在「Asset Manager」中,將滑鼠游標懸停在專案根目錄上,然後點選「data_usage」data_usage圖示。系統會顯示資訊對話方塊。

指令列

使用 Python 用戶端或程式碼編輯器查看資產配額。