def write_stats(self):
#if not hasattr(self, 'stack_count'):
stat_list = ['stack_count', 'stack_mean', 'stack_std', 'stack_min', 'stack_max']
if self.med:
stat_list.append('stack_med')
stat_list.append('stack_nmad')
if any([not hasattr(self, i) for i in stat_list]):
self.compute_stats()
print("Writing out stats")
#Create dummy ds - might want to use vrt here instead
driver = gdal.GetDriverByName("MEM")
ds = driver.Create('', self.ma_stack.shape[2], self.ma_stack.shape[1], 1, gdal.GDT_Float32)
ds.SetGeoTransform(self.gt)
ds.SetProjection(self.proj)
#Write out with malib, should preserve ma type
out_prefix = os.path.splitext(self.stack_fn)[0]
iolib.writeGTiff(self.stack_count, out_prefix+'_count.tif', ds)
iolib.writeGTiff(self.stack_mean, out_prefix+'_mean.tif', ds)
iolib.writeGTiff(self.stack_std, out_prefix+'_std.tif', ds)
iolib.writeGTiff(self.stack_min, out_prefix+'_min.tif', ds)
iolib.writeGTiff(self.stack_max, out_prefix+'_max.tif', ds)
if self.med:
iolib.writeGTiff(self.stack_med, out_prefix+'_med.tif', ds)
iolib.writeGTiff(self.stack_nmad, out_prefix+'_nmad.tif', ds)
评论列表
文章目录