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 资产被整理为由文件夹和集合组成的分层系统。其结构与常见文件系统类似。
根
资产归 Cloud 项目所有。项目名称定义了资源目录的根目录。例如,my-project
的根目录为 projects/my-project/assets
。属于 my-project
的所有素材资源都位于 projects/my-project/assets
文件夹或其子文件夹(或 ImageCollection)中。
目录
Earth Engine 使用树状目录结构来整理资源。每个 Cloud 项目都有一个根目录,其中可以包含各个素材资源和文件夹。ImageCollection 是一种特殊的素材资源类型,专门用于存储一组相关图片,例如时间序列或拼接图片。与文件夹不同,ImageCollection 只能包含图片素材资源,无法在其中嵌套其他文件夹或集合。
- folder_dataprojects/my-project/assets/
- folder folder-name/
- 照片 image-name
- view_comfy table-name
- 卫星 featureview-name
- bubble_chart classifier-name
- 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 获取资产的相关信息。
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 分析结果来创建资产)。
图片
使用 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.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
列出资产
使用 ee.data.listAssets
函数列出文件夹或集合中的资产(非递归)。如需详细了解过滤和分页,请参阅参考文档。
ee.data.listAssets('projects/my-project/assets')
展开素材资源管理器中的文件夹以查看素材资源。
使用 earthengine ls
命令可列出文件夹或合集中的素材资源(非递归)。如需详细了解如何限制要列出的资源数量和要返回的金额详情,请参阅参考文档。
earthengine ls projects/my-project/assets
设置资源权限
使用 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 应用的访问权限,方法是从下拉列表中选择应用的名称(由当前 Code Editor 项目拥有的资源)。
使用 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
如需了解详情,请参阅命令行参考文档页面。
检查资源权限
使用 ee.data.getAssetAcl
函数提取资产的访问控制列表。
ee.data.getAssetAcl('projects/my-project/assets/asset-name')
在素材资源管理器中,将指针悬停在某个素材资源上,然后点击分享图标。该对话框会显示电子邮件地址和网域的列表,以及各自的访问权限级别。
使用 earthengine acl get
命令提取资产的访问控制列表。
earthengine acl get projects/my-project/assets/asset-name
复制素材资源
使用 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
移动或重命名素材资源
使用 ee.data.renameAsset
函数移动或重命名资源。
ee.data.renameAsset('projects/my-project/assets/asset-name', 'projects/my-project/assets/new-asset-name')
Move
在素材资源管理器中,将素材资源拖动到新文件夹中。
重命名
在素材资源管理器中,将指针悬停在某个素材资源上,点击修改图标,然后在可修改的输入字段中输入新名称。
使用 earthengine mv
命令移动或重命名资源。
earthengine mv projects/my-project/assets/asset-name projects/my-project/assets/new-asset-name
删除资产
使用 ee.data.deleteAsset
函数删除资源。
ee.data.deleteAsset('projects/my-project/assets/asset-name')
点击某个素材资源以打开素材资源对话页面,然后点击删除按钮。
使用 earthengine rm
命令删除资源。如需了解递归和模拟运行选项,请参阅函数参考文档。
earthengine rm projects/my-project/assets/asset-name
查看资产元数据
使用 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
使用 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
查看素材资源配额
配额在项目级应用。如需详细了解资产配额,请参阅用量和配额限制页面。
使用 ee.data.getAssetRootQuota
函数获取资源根目录的存储配额用量。
ee.data.getAssetRootQuota('projects/my-project/assets')
在资源管理器中,将指针悬停在项目根目录上,然后点击 data_usage 图标。系统随即会显示一个信息对话框。
使用 Python 客户端或代码编辑器检查素材资源配额。