Earth Engine 资产是存储在平台内的项目拥有的地理空间数据。您可以上传自己的数据,并将 Earth Engine 分析生成的数据存储为资产。
资产类型
Earth Engine 为不同的数据类型提供各种资产格式,并提供用于整理的容器元素。
| 资产类型 | |
|---|---|
Image |
光栅,一种基于网格的地理信息表示形式,其中网格中的每个单元格都包含一个对应于地球表面特定位置的值。 |
ImageCollection |
构成拼接图或时序的一组相关光栅图片。它在功能上类似于文件夹,但可以作为 ee.ImageCollection 对象导入 Earth Engine,其中包含一组用于过滤和分析的方法。 |
Table |
由矢量地图项(行)组成的表数据结构,每个地图项都包含一系列属性(列)。它由 ee.FeatureCollection 对象表示,该对象包含一组用于过滤和分析的方法。 |
Classifier |
经过训练的 Earth Engine 机器学习模型。它由 ee.Classifier |
FeatureView |
用于 Earth Engine 应用的表格可视化视图。 |
Folder |
用于存放素材资源和其他文件夹的容器,有助于整理内容。 |
素材资源整理
Earth Engine 资产会整理到文件夹和集合的分层系统中。其结构与常见文件系统类似。
根
资产归云项目所有。项目名称定义了资源目录的根目录。例如,my-project 的根目录为 projects/my-project/assets。
属于 my-project 的所有资产都位于 projects/my-project/assets 文件夹或其中的子文件夹(或 ImageCollection)中。
目录
Earth Engine 使用树状目录结构来整理资产。 每个云项目都有一个根目录,其中可以包含单个资产和文件夹。ImageCollections 是一种特殊的素材资源类型,专门用于存放一组相关图片,例如时序或拼接图片。与文件夹不同,ImageCollection 只能包含图片资产,不能在其中嵌套其他文件夹或集合。
- folder_dataprojects/my-project/assets/
- folder folder-name/
- photo image-name
- view_comfy table-name
- satellite featureview-name
- bubble_chart classifier-name
- 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 和 TFRecord;Cloud Storage 中的 Cloud Optimized GeoTIFF (COG) 也可以就地注册,而无需提取。支持的表格格式包括 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'
)
代码编辑器
在 Asset Manager 中,点击新建按钮,然后从下拉列表中选择要上传或创建的资产类型。在对话框中配置素材资源上传或创建。
命令行
图片或表格
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
外部图片
Cloud Storage 存储桶中的 Cloud Optimized GeoTIFF (COG) 文件可以注册为 COG 支持的资产(在 API 中称为外部图片),并直接在 Earth Engine 中使用。如需了解如何构建清单,请参阅 COG 注册指南。
earthengine 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)
代码编辑器
在 Asset Manager 中,将指针悬停在某项资产上,然后点击共享图标。在对话框中,输入要与之共享资产的电子邮件地址或网域,然后从下拉列表中选择要授予的权限级别。点击添加访问权限按钮以确认更改。 选中“任何人都可以读取”复选框,向任何实体授予读取权限。您还可以通过从下拉列表中选择应用名称(由活跃代码编辑器项目拥有的资产),从对话框中提供对 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')
代码编辑器
在 Asset Manager 中,将指针悬停在某项资产上,然后点击共享图标。该对话框会显示电子邮件地址和网域列表,以及它们各自的访问权限级别。
命令行
使用 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')
代码编辑器
Move
在素材资源管理器中,将素材资源拖动到新文件夹中。
重命名
在 Asset Manager 中,将指针悬停在某项资产上,然后点击修改图标,并在可修改的输入字段中输入新名称。
命令行
使用 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 客户端或代码编辑器查看资产配额。