def get_cloud_rate(scene_name):
"""Read the MTL file and return the cloud_rate of the scene."""
sat = 'L%s' % scene_name[2]
mtl_path = join(settings.MEDIA_ROOT, sat, scene_name, scene_name + '_MTL.txt')
if isfile(mtl_path):
with open(mtl_path, 'r') as f:
lines = f.readlines()
cloud_rate = [float(line.split(' = ')[-1]) for line in lines if 'CLOUD_COVER' in line][0]
return cloud_rate
else:
url_code = get_metadata_code(scene_name)
metadata = PyQuery(
'http://earthexplorer.usgs.gov/metadata/%s/%s/' % (url_code, scene_name)
)
metadata = metadata.text()[metadata.text().find('Cloud Cover '):]
return float(metadata.split(' ')[2])
评论列表
文章目录