行星夹装运工具
pclip的Python项目详细描述
clip ship planet cli插件
注意:clips api已经被弃用,不再支持独立的clip和ship服务。deprecation意味着在某个时刻有删除服务的意图;它还不意味着服务的生命周期结束。(不推荐使用和终止使用是两个不同的术语。)应该计划用新的预处理功能替换clips api,但是没有发布新服务和删除clips api(终止使用)的新公告或时间表。
planet的clip api是一个计算api,它允许用户将图像剪辑到感兴趣的区域。这将节省他们的预处理时间,也允许用户保存他们的区域配额,这可能有限制。根据《星球》的教育和研究计划,这个配额是每月10000平方公里,这意味着节省配额是非常有用的。讨论还导致了一个重要的澄清,即如果用户使用clip操作,实际上只对下载的post clip区域收费,因此该工具也收费。这个工具采用一种顺序的方法,从激活到为激活的多个图像生成剪辑请求,然后处理下载令牌来实际下载剪辑的图像文件。该工具还包括一个排序功能,允许用户提取文件并按类型排序,删除原始文件以节省空间。
安装
要安装cli p ship planet cli,只需在linux上执行以下操作(在ubuntu 16上测试):
git clone https://github.com/samapriya/Clip-Ship-Planet-CLI.git
cd Clip-Ship-Planet-CLI && pip install -r requirements.txt
在windows和linux机器上,安装是一个可选步骤;应用程序也可以通过执行pclip.py脚本直接运行。安装它的好处是可以作为任何命令行工具执行ppipe。我建议在虚拟环境中安装,但您也可以将其安装到系统python中,并且不应创建任何冲突。要在Windows上安装,请将安装文件作为zip包下载,解压缩并运行
python setup.py develop or python setup.py install
在Linux发行版中
sudo python setup.py develop or sudo python setup.py install
pclip -h
目录
开始
如往常一样,要打印帮助:
Planet Clip Tools CLI
positional arguments:
{ ,planetkey,aoijson,activate,aoiupdate,idlist,geojsonc,jsonc,downloadclips,sort}
-------------------------------------------
-----Choose from Planet Clip Tools-----
-------------------------------------------
planetkey Enter your planet API Key
quota Prints your quota details
aoijson Tool to convert KML, Shapefile,WKT,GeoJSON or Landsat
WRS PathRow file to AreaOfInterest.JSON file with
structured query for use with Planet API 1.0
activate Tool to query and/or activate Planet Assets
idlist Allows users to generate an id list for the selected
item and asset type for example item_asset=
PSOrthoTile analytic/PSScene3Band visual. This is used
with the clip tool
geojsonc Allows users to batch submit clipping request to the
Planet Clip API using geometry in geojson file
jsonc Allows users to batch submit clipping request to the
Planet Clip API using geometry in structured json
file. This is preferred because the structured JSON
allows the activate tool to stream line asset ids
being requested and to extract geometry from the same
file
downloadclips Allows users to batch download clipped assets post
computation using a directory path(Requires you to
first activate and run geojson or json tool)
sort Allows users to unzip downloaded files to new folder
and sorts into images and metadata
optional arguments:
-h, --help show this help message and exit
用法示例
这些工具的设计遵循从激活、剪辑、下载到排序的顺序设置,包括帮助解决用户在尝试下载剪辑的感兴趣区域而不是整个场景时可能遇到的其他问题的步骤。系统将要求您在cli启动之前输入api密钥(这将只提示您使用planet key工具更改一次api密钥)。
行星键
这个工具基本上要求你输入你的星球api密钥使用密码提示,然后用于所有后续工具。ITES使用Planet客户端,并按需执行Planet init
usage: pclip planetkey [-h]
optional arguments:
-h, --help show this help message and exit
行星配额
此工具打印有关您现有配额和剩余区域的详细信息
usage: pclip quota
optional arguments:
-h, --help show this help message and exit
AOI JSON
工具集中的aoijson选项卡允许您创建过滤器,并将现有的输入文件结构为可与planet的api一起使用的文件。该工具需要输入起始日期和结束日期以及云覆盖。您可以根据路径行号从多个输入文件类型中进行选择,例如KML、压缩shapefile、geoJSON、wkt甚至Landsat tiles。geo选项要求您选择现有文件,这些文件将被转换为格式化的json文件aoi.json。如果使用wrs作为选项,只需输入6位的pathrow组合,它将为您创建一个json文件。
usage: pclip aoijson [-h] [--start START] [--end END] [--cloud CLOUD]
[--inputfile INPUTFILE] [--geo GEO] [--loc LOC]
optional arguments:
-h, --help show this help message and exit
--start START Start date in YYYY-MM-DD?
--end END End date in YYYY-MM-DD?
--cloud CLOUD Maximum Cloud Cover(0-1) representing 0-100
--inputfile INPUTFILE
Choose a kml/shapefile/geojson or WKT file for
AOI(KML/SHP/GJSON/WKT) or WRS (6 digit RowPath
Example: 023042)
--geo GEO map.geojson/aoi.kml/aoi.shp/aoi.wkt file
--loc LOC Location where aoi.json file is to be stored
pclip aoijson--start"2017-06-01"--end"2017-12-31"--cloud"0.15"--inputfile"gjson"--geo"c:\行星\myarea.geojson"--loc"c:\行星"
输出总是命名为aoi.json。
激活或检查资产
激活工具允许用户检查或激活行星资源。这个工具使用了一个现有的json文件,该文件是为在planet api中使用而构建的,或者是前面创建的aoi.json文件。这是一个必要的步骤,因为clip api只能处理那些已激活的id。将来,列表ID工具将检查激活的ID的数量,并等待所有这些ID都被激活,然后再生成ID列表。
usage: pclip activate [-h] [--aoi AOI] [--action ACTION] [--asst ASST]
optional arguments:
-h, --help show this help message and exit
--aoi AOI Choose aoi.json file created earlier
--action ACTION choose between check/activate
--asset ASST Choose between planet asset types (PSOrthoTile
analytic/PSOrthoTile analytic_dn/PSOrthoTile
visual/PSScene4Band analytic/PSScene4Band
analytic_dn/PSScene3Band analytic/PSScene3Band
analytic_dn/PSScene3Band visual/REOrthoTile
analytic/REOrthoTile visual
资产激活的示例设置如下
pclip activate--aoi"c:\ planet\aoi.json"--action"activate"--asset"psorthotile analytic"
列表ID
下一步是列出已激活的id,这将创建一个包含id列表的临时文件,该列表可用于迭代调用clips api。这是对激活功能的修改,只使用项目ID而不是项目类型和资产ID,并写入文件以备将来使用。
usage: pclip idlist [-h] [--aoi AOI] [--asset ASSET]
optional arguments:
-h, --help show this help message and exit
--aoi AOI Input path to the structured json file from which we will
generate the clips
--asset ASSET Choose from asset type for example:"PSOrthoTile
analytic"|"REOrthoTile analytic"
此命令的示例设置如下
pclip idlist--aoi"c:\ planet\aoi.json--asset"psorthotile analytic"
使用geojson剪裁
geejson文件可以直接用于剪辑和查询感兴趣的区域,然后提交剪辑过程。我添加了这是一个功能,但要明确指出,这不考虑任何其他过滤器,如云覆盖或开始和结束日期,因此应仅在不需要应用任何过滤器时使用。
git clone https://github.com/samapriya/Clip-Ship-Planet-CLI.git
cd Clip-Ship-Planet-CLI && pip install -r requirements.txt
0
json工具的一个简单设置如下
pclip geojson c--path"c:\ planet\aoi.geojson"--item"psorthotile"--asset"analytic"
使用json剪裁
这是首选的使用前面生成的idlist提交clip请求的方式。这在激活资产之前就已经有了结构,并且包含了用于选择图像的附加过滤器。
git clone https://github.com/samapriya/Clip-Ship-Planet-CLI.git
cd Clip-Ship-Planet-CLI && pip install -r requirements.txt
1
json工具的一个简单设置如下
pclip json c--path"c:\ planet\aoi.json"--item"psorthotile"--asset"analytic"
下载剪辑图像
最后一步包括提供可以下载剪辑图像的位置。这包括从前面步骤生成的zip文件,并包括一个随时间过期的下载令牌。此批将压缩的zip文件下载到目标目录
git clone https://github.com/samapriya/Clip-Ship-Planet-CLI.git
cd Clip-Ship-Planet-CLI && pip install -r requirements.txt
2
一个简单的设置仅包括要下载的压缩文件的下载目录位置
git clone https://github.com/samapriya/Clip-Ship-Planet-CLI.git
cd Clip-Ship-Planet-CLI && pip install -r requirements.txt
3
排序
作为一项附加措施,并且由于它使数据集的排列和处理变得容易,因此此设置使用排序工具完成。如果为解压缩的文件提供了输出目录,工具将解压缩所有文件,将图像和元数据移动到单独的目录,然后删除原始的压缩文件以节省空间。
git clone https://github.com/samapriya/Clip-Ship-Planet-CLI.git
cd Clip-Ship-Planet-CLI && pip install -r requirements.txt
4
一个简单的方法如下(图像和元数据被分类到解压文件文件夹中的图像和元数据文件夹中)
git clone https://github.com/samapriya/Clip-Ship-Planet-CLI.git
cd Clip-Ship-Planet-CLI && pip install -r requirements.txt
5
更改日志
v0.2.6
- 在py2和py3中处理urllib兼容性问题
v0.2.2
- 改进的行星钥匙手柄
- 为Inspect Planet帐户配额添加了新工具
v0.2.1
- 感谢Rabscutler建议的提交
- 修复了帮助文本和安装程序的问题
v0.2.0
- 修复了配置文件的问题
v0.1.9
- 现在可以更好地处理运行和成功状态
- 现在在剪辑和下载期间枚举,以允许用户估计剪辑和/或下载的资产数量
v0.1.8
- 在安装程序中包括必需的软件包列表
- 健壮的geojson解析
v0.1.7
- 修复了处理可视资产类型的问题
- clip函数现在处理错误代码如果post response code不是202(接受处理),则打印错误代码、项目和资产类型。
v0.1.6
- 处理单次输入API密钥,启动程序只需一次
- 修复了排序期间基本元数据文件夹的问题
- 更新了资产激活的资产参数以匹配样式
v0.1.5
- 更新了requirements.txt以包含pyshp
- 修复了子进程shell错误,目前shell=true
v0.1.4
- 一般改进
v0.1.3
- 一般改进
v0.1.2
- 在ubuntu 16.04上测试,现在处理权限问题
- 临时文件现在写入配置文件夹以避免管理员权限
v0.1.1
- 一般改进