for date in unique_dates: for index in index_names: index_files = [os.path.join(path_indices, index, f) for f in fnmatch.filter( os.listdir(os.path.join(path_indices, index)), "*" + dt.datetime.strftime(date, "%Y%m%d") + "*.tif")] if len(index_files) == 0: print("No indices found for %s" % dt.datetime.strftime(date, "%Y%m%d")) continue sensor_code = os.path.basename(index_files[0])[:3] vrt_file_name = os.path.join(path_indices, index, sensor_code + "_" + dt.datetime.strftime(date, "%Y%m%d") + "_" + index + ".vrt") try: rsu.createVRT(index_files, vrt_file_name, separate=False) except Exception as e: if not DEBUG: progress.setText("ERROR: %s" % e) else: print e if not DEBUG and index == "NDWI": try: dataobjects.load(vrt_file_name, os.path.basename(vrt_file_name), isRaster=True) except: dataobjects.load(vrt_file_name, os.path.basename(vrt_file_name)) # Update progress bar if not DEBUG: progress.setPercentage(100)
dt.datetime.strftime(date, "%Y%m%d") + "*.tif") ] if len(inFiles) == 0: print("No indices found for %s" % dt.datetime.strftime(date, "%Y%m%d")) continue sensorCode = os.path.basename(inFiles[0])[:3] if sensor == "Landsat": mergedOutfile = os.path.join( path_indices, index, sensorCode + "_" + dt.datetime.strftime(date, "%Y%m%d") + "_" + index + ".vrt") else: mergedOutfile = os.path.join( path_indices, index, sensorCode + "_" + dt.datetime.strftime(date, "%Y%m%d") + "_" + index + ".vrt") try: rsu.createVRT(inFiles, mergedOutfile, separate=False) except Exception as e: if not debug: progress.setText("ERROR: %s" % e) else: print e # Update progress bar if not debug: progress.setPercentage(100)