上个博客介绍了几种Sentinel数据快速下载的方法,没看到的biubiubiu→→→→→→→→→→→→→→→→→→→→
接下来分享一下如何在python下调用cmd使用sen2cor批量对Sentinel2数据大气校正!
话不多说,上才艺,EGM...
搞错了,上代码!
# author='zhanggd'
# date='2020/02/06'
import subprocess
import zipfile
import os
sen2cor_path = r"F:\SEN2COR\Sen2Cor-02.08.00-win64\L2A_Process.bat"
origin_dir = r"F:\L1C"
pattern = ".SAFE"
for in_file in os.listdir(origin_dir):
if pattern in in_file:
zip_file_path = os.path.join(origin_dir, in_file)
#print(zip_file_path)
xml_file_path=zip_file_path
xml_file_path1 = os.path.basename(xml_file_path)
xml_file_path2 =('F:/L1C/'+xml_file_path1)
os.chdir(xml_file_path2)
print(os.getcwd())
#cmd_args = [sen2cor_path, xml_file_path, \
# '--output_dir', output_dir]
cmd_args = [sen2cor_path, xml_file_path]
print(cmd_args)
subprocess.call(cmd_args)
这代码无敌了!简单粗暴!就连从没写过程序的人都能看懂!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
因为是今年2月份做实验时写的代码,这里就不上运行截图了,数据不知道扔哪里去了,但是保证可用!!!!!!!!!!
用了这个代码,妈妈再也不担心我一幅一幅校正了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
数据处理全靠挂机!挂机一整晚,数据全部处理完,一点不浪费时间!!!!!!!!!!!!!!!!!!!!!!!!
对,就那绿的那两行,改下路径就行了,把你的数据存放路径和sen2cor所在路径copy上去就行!!!!!!!!!!!!
什么?还不会?还有问题?
赶紧私信我吧,私信必回!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
必回!