python在遥感中的应用_利用Python下载Landsat数据

尽管Landsat数据应用广泛,但是数据下载一直都是比较困难的事情。国内数据一般采用地理空间数据云或者中科院的网站勉强都可以搞定。但是国外的数据一般很难下载到。这里面主要存在两个问题:

1)因为下载数据的网站经常性连接不上,包括EarthExplore和Glovis。

2)批量数据下载困难。

最近在思考如何更简单的进行数据的批量下载。下面介绍一下使用方法,代码依然采用的是Python。下载方式其实非常简单,主要用到landsatxplore这个库,这个库的github地址是https://github.com/yannforget/landsatxplore。里面有详细的介绍,我主要介绍一下我的使用心得。使用前,你需要先注册EarthExplore的账户,记住你的username 和 password

安装:

pip install landsatxplore

用户登录:

api = landsatxplore.api.API(username, password)

数据搜索:这里面我没换位置,因为显然经纬度的点在国外,数据集你可以选择TM,ETM和Landsat8 (LANDSAT_TM_C1|LANDSAT_ETM_C1|LANDSAT_8_C1),这里我以Landsat8为例,设置数据筛选时间,云量

scenes = api.search(

dataset='LANDSAT_8_C1',

latitude=19.53,

longitude=-1.53,

start_date='2014-01-01',

end_date='2016-01-01',

max_cloud_cover=10)

数据筛选结果:

385be39a0c3b47de88ad2c17aa80b945.png

数据下载:

Earth_Down = EarthExplorer(username, password)

Earth_Down.download(scene_id='LC81960462014022LGN01', output_dir='E:\data')

数据下载结果:

357ac67ccf3946d2bd1f78028649bce3.png

下载速度大概4M/s,速度还可以。目前批量下载没有问题,就是还不清楚批量下载是网络连接是不是稳定。

详细代码如下:

import landsatxplore.api

from landsatxplore.earthexplorer import EarthExplorer

def request_Landsat(username,password,product,lat,lon,start_date,end_date,cloud_max):

api = landsatxplore.api.API(username, password)

scenes = api.search(

dataset=product,

latitude=lat,

longitude=lon,

start_date=start_date,

end_date=end_date,

max_cloud_cover=cloud_max)

print('{} scenes found.'.format(len(scenes)))

api.logout()

return scenes

def download_landsat(username,password,Landsat_name,output_dir):

Earth_Down = EarthExplorer(username, password)

for scene in Landsat_name:

ID = scene['entityId']

print('Downloading data %s '% ID)

Earth_Down.download(scene_id=ID, output_dir=output_dir)

Earth_Down.logout()

if __name__ == '__main__':

username = ''

password = ''

product = 'LANDSAT_8_C1'

lat = 19.53

lon = -1.53

start_date='2014-01-01'

end_date='2016-01-01'

cloud_max = 10

output_dir = '.\data'

Landsat_name = request_Landsat(username,password,product,lat,lon,start_date,end_date,cloud_max)

download_landsat(username,password,Landsat_name,output_dir)

d1d93cca90d447ddbadd44cfa6a2b8d2.jpg

祝好!

2020.01.02

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值