最近需要下载同一景的sentinel数据,最后搜了一下决定使用python

使用的python包如该链接https://pypi.org/project/sentinelsat/

里面也有详细说明文档

因此这里只粘贴代码了

from sentinelsat.sentinel import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date
from collections import OrderedDict

# connect to the API
api = SentinelAPI('****', '****', 'https://scihub.copernicus.eu/dhus')

# download single scene by known product id
#api.download(<product_id>)

# search by polygon, time, and Hub query keywords
#footprint = geojson_to_wkt(read_geojson('map.geojson'))date = ('2015-01-01T08:17:06Z','2016-01-01T01:12:15Z')

footprint='POLYGON((-22.8515625 76.382969, 15.029296875 76.38297, 15.029296875 81.678786, -22.8515625 81.678786, -22.8515625 76.382969))'
products = api.query(area=footprint,date=('20180101', date(2018, 1,31)),filename='S1B_*',
                     platformname = 'Sentinel-1',relativeorbitnumber=24,polarisationmode='HH HV',producttype='GRD',swathidentifier='EW')
#print(products)
downfiles=OrderedDict()
for i in products:
    product=products[i]
    filename=product['filename']
    print(filename) 
    #print filename[26:30]
    if filename[26:30] == '0817':
        downfiles[i]=product
        print('YES,it works!')        
       # api.download(i)
    else:
        print('NO!')
        products.pop(i)
        
        
# download all results from the search
successfile=api.download_all(products)

# GeoJSON FeatureCollection containing footprints and metadata of the scenes
#api.to_geojson(products)

# GeoPandas GeoDataFrame with the metadata of the scenes and the footprints as geometries
#api.to_geodataframe(products)

# Get basic information about the product: its title, file size, MD5 sum, date, footprint and
# its download url
#api.get_product_odata(<product_id>)

# Get the product's full metadata available on the server
#api.get_product_odata(<product_id>, full=True)

目前代码还有没有完善的地方是,如果出现异常则下载就会中断,程序无法继续,还在修改当中

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐