1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
import landsatxplore.api from landsatxplore.earthexplorer import EarthExplorer
def request_Landsat(username,password,product,bbox,start_date,end_date,cloud_max): api = landsatxplore.api.API(username, password) scenes = api.search( dataset=product, bbox=bbox, start_date=start_date, end_date=end_date, max_cloud_cover=cloud_max) print('{} data queried.'.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 %s '% ID) Earth_Down.download(scene_id=ID, output_dir=output_dir) Earth_Down.logout()
if __name__ == '__main__': username = '' password = '' product = 'LANDSAT_TM_C1' bbox = [34, 119, 35, 120] start_date='1999-01-01' end_date='2000-01-01' cloud_max = 10 output_dir = 'E:\\LandsatImg\\' Landsat_name = request_Landsat(username,password,product,bbox,start_date,end_date,cloud_max) download_landsat(username,password,Landsat_name,output_dir)
|