/edl-scripts/tif2bil-native.py
Python | 25 lines | 23 code | 1 blank | 1 comment | 5 complexity | cc4657a86e513b4c80c267ecba76e213 MD5 | raw file
1#!/usr/bin/python 2import os 3import shutil 4import edlconfig 5 6for root, dirs, files in os.walk(edlconfig.dataset): 7 for name in files: 8 if name.endswith(".geotiff"): 9 layername = name.replace(".geotiff","") 10 print(layername) 11 12 p = os.popen(edlconfig.gdalapps+"/gdalinfo -mm " + os.path.join(root,name),"r") 13 while 1: 14 line = p.readline() 15 if not line: break 16 if "Type" in line: 17 dataType = line.split("Type=")[1].split(",")[0] 18 if dataType == "Int32": #Diva can't handle Int32 19 dataType = "Float32" 20 command = edlconfig.gdalapps+"/gdalwarp -ot " + dataType + " -s_srs '" + edlconfig.s_srs + "' -t_srs '" + edlconfig.t_srs + "' -of EHdr -srcnodata -9999 -dstnodata -9999 " + os.path.join(root,layername) + ".geotiff " + os.path.join("/data/ala/data/source/native-bil",layername) + ".bil" 21 22 print(command) 23 os.system(command) 24 25