美文网首页@EZ翻译计划
EZ | Command Line Tool | GEE - 0

EZ | Command Line Tool | GEE - 0

作者: 杜若飞er | 来源:发表于2019-07-22 14:14 被阅读0次

    earthengine工具是一个实用的程序,用来管理你的GEE资产库和命令行的任务,当你安装Python的API时,它应该被自动安装好了,如果想检查它是否被安装,就在命令行里输入如下命令:
    earthengine
    如果安装顺利,它就应该输出一个简短的可用信息,想要获得更多帮助,使用如下命令:
    earthengine command -h
    如果你是首次安装Python的API,你需要使用authenticate登陆,下面的部分就会对展示可用命令的更多细节。
    Command\ Reference


    命令参考手册

    authenticate
    用来激活命令行工具,使用方法如下:
    earthengine authenticate
    GEE使用OAuth 2.0 protocol技术对激活进行处理,可以在 这里得到更多细节。

    acl
    acl命令可以对ACL进行更新,ACL是对于资产库文件读写权限的控制信息,如下使用:

    earthengine acl get users/username/asset_id
    earthengine acl set public users/username/asset_id
    earthengine acl ch -u username@gmail.com:R users/username/asset_id
    

    其中,get能得到一个ACL的JSON描述,set提供了一个对于ACL的设置,你可以使用这两个命令从一个资源库中拷贝ACL并方便地分发出去。
    ACL有两种特殊命名:

    • private:除了owner之外,其他人无法使用。
    • public:给予所有user以读权限。

    ch能让你对一个ACL做微调,使用-u username@gmail.com:R把读权限授予给某人,-u username@gmail.com:W则授予了写权限,-d username@gmail.com则可以剥夺某人的权限,也可以使用AllUsers这个特殊用户对权限做处理。

    asset
    用来输出并更新GEE的元数据:

    earthengine asset info users/username/asset_id
    earthengine asset set -p name=value users/username/asset_id
    

    info子命令将把资产的详细信息以JSON格式输出出来(也包括元数据),set则设置单个的元数据属性。
    设置元属性的值可以是数字,也可以是字符串,使用--property-p标志字段设置属性名称时将自动检测数据类型,或者可以加上stringnumberdata来明确指定数据类型,例如,可以讲值设置为42,如下操作:
    earthengine asset set -p '(string)name=42' users/username/asset_id
    (此示例中的引号是一个转义字符,根据你的shell和平台,也有可能用不上它们。)
    日期属性表示来自Unix的时间格式,可以指定为以下的方式:

    YYYY-MM-DD
    YYYY-MM-DDThh:mm:ss
    YYYY-MM-DDThh:mm:ss.f
    

    假定时区为UTC,可以使用--time_start--time_end标志字段来设置特殊的时间属性。

    earthengine asset set --time_start 1978-10-15T12:34:56 users/username/asset_id
    

    cp
    建立一个资产的拷贝,这样做:

    earthengine cp users/username/asset_id users/username/new_asset_id
    

    create
    创建一个新的文件夹或图像集:

    earthengine create folder users/username/folder_id
    earthengine create collection users/username/collection_id
    

    使用folder子命令创建文件夹,collection子命令创建图像集。可以选择-p字段递归创建父文件夹,新建的文件夹或图像自动创造私有权限的ACL。

    ls
    列出文件夹或图像集的所有实体:

    earthengine ls users/username
    

    -l字段可以得到更多信息,也可以使用--max_items number或是-m字段对列出的实体数量进行限制:

    earthengine ls -m 10 users/username/my_large_collection
    

    不指明文件夹的情况下使用ls命令会列出顶层文件夹内容。

    mv
    移动或是对实体重命名:

    earthengine mv users/username/asset_id users/username/new_asset_id
    

    rm
    删除:

    earthengine rm users/username/asset_id
    earthengine rm -r users/username/folder_id
    

    可以特地加上-r字段删除文件夹或是图像集的内容,可以使用--dry_run字段验证确认删除内容而不会真正删除任何内容。

    tasks
    输出信息,并管理长期任务:

    earthengine task list
    earthengine task info TASK_ID
    earthengine task cancel TASK_ID
    

    list字命名列出了最近提交任务的基本信息,info子命令输出各个任务的详细信息,cancel子命令用来取消任务。

    upload
    把Google Cloud Storage里的图像或是表格传到GEE里:

    earthengine upload image --asset_id=users/username/asset_id gs://bucket/image.tif
    

    如果制定了多张输入图像文件,他们就会被当作单个来处理。用户可以这里详细了解上传的诸多选项。
    可以使用--pyramiding_policy字段指定金字塔(pyramid)减少策略(默认),字段可以设置为samplemodemin或是max。而这将会控制GEE生成图像的低分辨率版的金字塔。

    earthengine upload image --asset_id=users/username/asset_id --pyramiding_policy=sample gs://bucket/image.tif
    

    可以使用--last_band_alpha字段标定图像的遮盖值应当从最后一个波段的alpha通道获得:

    earthengine upload image --asset_id=users/username/asset_id --last_band_alpha gs://bucket/image.tif
    

    使用--nodata_value字段来表示一个没有数据的值,这将会遮盖掉某些像素点:

    earthengine upload image --asset_id=users/myuser/asset --nodata_value=255 gs://bucket/image.tif
    

    也可以使用相同的字段对元数据进行设置。
    想要从Google Cloud Storage中上传一个ShapefileCSV或是TFRecord文件,可以使用如下命令:

    earthengine upload table --asset_id=users/username/myUploadedShapefile gs://bucket/foo.shp
    
    earthengine upload table --asset_id=users/username/myUploadedCSV gs://bucket/foo.csv
    
    earthengine upload table --asset_id=users/username/myUploadedTFRecord gs://bucket/foo.tfrecord
    

    注意,当上传Shaoefile文件时,只需要指定.shp文件的路径,相关的.dbf、.shx和.prj文件应当放在同一位置。或者,你可以直接指定一个包含有它们的zip压缩包。
    在涉及到CSV或是TFRecord时,有一些可选字段,可以使用这个命令看到完整的列表:

    earthengine upload table -h
    

    \tag{本页面最后更新于2019年4月3日}

    相关文章

      网友评论

        本文标题:EZ | Command Line Tool | GEE - 0

        本文链接:https://www.haomeiwen.com/subject/uxeulctx.html