从EarthExplorer搜索并下载陆地卫星场景。

landsatxplore的Python项目详细描述


说明

CLI Demo

landsatxplorepython包提供了一个到EarthExplorer门户的接口,用于通过命令行接口或python api搜索和下载Landsat Collections场景。

它支持三个数据集:LANDSAT_TM_C1LANDSAT_ETM_C1LANDSAT_8_C1

快速启动

搜索包含1995年期间获得的位置(12.53,-1.53)的陆地卫星5 TM场景。

landsatxplore search --dataset LANDSAT_TM_C1 --location 12.53 -1.53 \
    --start 1995-01-01 --end 1995-12-31

在布鲁塞尔寻找陆地卫星7 ETM场景,云量不到5%。将返回的结果保存到.csv文件中。

landsatxplore search --dataset LANDSAT_ETM_C1 \
    --location 50.83 4.38 --clouds 5 > results.csv

从当前目录中的不同数据集下载三个陆地卫星场景。

landsatxplore download LT51960471995178MPS00 LC80390222013076EDC00 LC82150682015350LGN01

要使用包,需要地球资源管理器凭据(registration)。

安装

可以使用pip安装包。

pip install landsatxplore

用法

landsatxplore既可以通过其命令行界面使用,也可以作为python模块使用。

命令行界面

landsatxplore --help
Usage: landsatxplore [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  download  Download one or several Landsat scenes.
  search    Search for Landsat scenes.

证书

可以获得地球资源管理器门户的凭据here

--username--password可以作为命令行选项或环境变量提供:

exportLANDSATXPLORE_USERNAME=<your_username>
exportLANDSATXPLORE_PASSWORD=<your_password>

搜索

landsatxplore search --help
Usage: landsatxplore search [OPTIONS]

  Search for Landsat scenes.

Options:
  -u, --username TEXT             EarthExplorer username.
  -p, --password TEXT             EarthExplorer password.
  -d, --dataset [LANDSAT_TM_C1|LANDSAT_ETM_C1|LANDSAT_8_C1]
                                  Landsat data set.
  -l, --location FLOAT...         Point of interest (latitude, longitude).
  -b, --bbox FLOAT...             Bounding box (xmin, ymin, xmax, ymax).
  -c, --clouds INTEGER            Max. cloud cover (1-100).
  -s, --start TEXT                Start date (YYYY-MM-DD).
  -e, --end TEXT                  End date (YYYY-MM-DD).
  -o, --output [scene_id|product_id|json|csv]
                                  Output format.
  -m, --limit INTEGER             Max. results returned.
  --help                          Show this message and exit.

下载

landsatxplore download --help
Usage: landsatxplore download [OPTIONS] [SCENES]...

  Download one or several Landsat scenes.

Options:
  -u, --username TEXT  EarthExplorer username.
  -p, --password TEXT  EarthExplorer password.
  -o, --output PATH    Output directory (default to current).
  --help               Show this message and exit.

API

接地探测器API

landsatxplore提供了一个到地球资源管理器json api的接口。有关可能的请求代码和参数,请参阅官方(documentation)。

基本用法

importlandsatxplore.api# Initialize a new API instance and get an access keyapi=landsatxplore.api.API(username,password)# Perform a request. Results are returned in a dictionnaryresponse=api.request('<request_code>',parameter1=value1,parameter2=value2)# Log outapi.logout()

搜索场景
importlandsatxplore.api# Initialize a new API instance and get an access keyapi=landsatxplore.api.API(username,password)# Requestscenes=api.search(dataset='LANDSAT_ETM_C1',latitude=19.53,longitude=-1.53,start_date='1995-01-01',end_date='1997-01-01',max_cloud_cover=10)print('{} scenes found.'.format(len(scenes)))forsceneinscenes:print(scene['acquisitionDate'])api.logout()

输出:

8 scenes found.
1995-05-10
1995-05-26
1995-06-11
1995-06-11
1995-06-27
1995-07-29
1995-08-14
1995-08-14

下载场景
fromlandsatxplore.earthexplorerimportEarthExploreree=EarthExplorer(username,password)ee.download(scene_id='LT51960471995178MPS00',output_dir='./data')ee.logout()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何在Java和Javascript之间共享常量   c#无法使用Gson反序列化字节[]   如果字符串是实十进制数字,则在Java中仅显示十进制数字   与Android Studio的java FireBase同步失败   web应用程序的Java Oracle数据库更改通知问题   数组中缺少整数的java嵌套循环   zos在z/os上以TOD格式(一天中的时间)转换Java时间戳   java JAXB未根据注释生成XML(JDK 1.7)   java使用Twitter4j和Geolocation查找在该地区发布推文的用户,但如何获取用户ID?   在Libgdx中实现简单运动模糊的java意外结果   java在Android数据库中插入另一个EditText值?   java标准偏差数组(我的算法错误)   java如何修复M1 Mac的Ant javascript标记?   java遍历树标记值的长度   java理解Springboot中的Cron,自动发送电子邮件   java如何将“Data.Json”文件从资产保存到内部存储器,然后将其用于读/写   java代码在编写FirstDuplicate方法时会遇到时间限制问题   java将HTML转换为PDF并将其添加到段落中   javascript css()未设置正文标记的背景属性