从EarthExplorer搜索并下载陆地卫星场景。
landsatxplore的Python项目详细描述
说明
landsatxplorepython包提供了一个到EarthExplorer门户的接口,用于通过命令行接口或python api搜索和下载Landsat Collections场景。
它支持三个数据集:LANDSAT_TM_C1
、LANDSAT_ETM_C1
和LANDSAT_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