简体   繁体   English

ComputeBandStats非常慢

[英]ComputeBandStats extremely slow

When I try to use ComputeBandStats it takes extremely long time to finish. 当我尝试使用ComputeBandStats时,需要很长时间才能完成。 Is there any way to speed up the process? 有没有办法加快这个过程?

Here is my code: 这是我的代码:

inIMG = gdal.Open(infile)
bandas = [inIMG.GetRasterBand(b+1) for b in range(3)]
print('hej1')
meanSD = [b.ComputeBandStats(1) for b in bandas]
print('hej2')

It prints out "hej1" pretty fast, but it only writes "hej2" after several hours. 它打印出“hej1”非常快,但它只在几个小时后写入“hej2”。 Therefore it seems that ComputeBandStats is the problem. 因此,似乎ComputeBandStats是问题所在。

I tried it with no parameter (has worked at an earlier date) and with 1, but it doesn't seem to make any difference. 我尝试了没有参数(已经在较早的日期工作)和1,但它似乎没有任何区别。

(I am using python 2.7 and gdal 1.11.3) (我使用的是python 2.7和gdal 1.11.3)

I found out that ComputeStatistics is much faster than ComputeBandStats, so I'm using it instead. 我发现ComputeStatistics比ComputeBandStats快得多,所以我正在使用它。 I don't know exactly what the difference is, but aside from the speed advantage, ComputeStatistics also ignores no-data values, which turned out to be a problem for ComputeBandStats. 我不确切地知道区别是什么,但除了速度优势之外,ComputeStatistics还忽略了无数据值,这对ComputeBandStats来说是一个问题。 It also calculates min, max, mean and std, which I all needed anyways. 它还计算min,max,mean和std,这些都是我所需要的。

This is the change I made: 这是我做的改变:

inIMG = gdal.Open(infile)
bandas = [inIMG.GetRasterBand(b+1) for b in range(3)]
print('hej1')
stats = [b.ComputeStatistics(False) for b in bandas]
print('hej2')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM