utils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:imagery 作者: cenima-ibama 项目源码 文件源码
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])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号