-
Notifications
You must be signed in to change notification settings - Fork 115
Description
Hi,
I think there is an error in calculating mean and standard deviation in rasterstats 0.10.3
Here is the statistics calculated in ArcMap for my region:
Band COUNT MIN MAX MEAN STD MEDIAN
1 151057 1378 2399 1584 71 1577
2 151057 1025 2753 1318 119 1305
3 151057 594 3271 1035 191 1014
4 151057 380 3636 854 223 826
5 151057 113 4225 753 252 718
6 151057 366 4869 1853 642 1808
7 151057 153 7181 2947 1099 2873
8 151057 121 5926 2577 916 2519
9 151057 13880 59141 51615 3675 52475
10 151057 14939 44531 37989 1722 38133
11 151057 10063 56708 48523 3707 49289
12 151057 13024 46146 34272 5463 34959
13 151057 23169 59005 46253 3292 46804
And here is the same statistics calculated using rasterstats (have a look at mean and std values for bands 9-13):
Band count min max mean std percentile_50
1 151057 1378 2399 1584 71 1577
2 151057 1025 2753 1318 119 1305
3 151057 594 3271 1035 191 1014
4 151057 380 3636 854 223 826
5 151057 113 4225 753 252 718
6 151057 366 4869 1853 642 1808
7 151057 153 7181 2947 1099 2873
8 151057 121 5926 2577 916 2519
9 151057 13880 59141 23182 28669 52475
10 151057 14939 44531 9556 28485 38133
11 151057 10063 56708 20090 28673 49289
12 151057 13024 46146 5839 28953 34959
13 151057 23169 59005 17820 28623 46804
The code to reproduce the results using rasterstats:
for i in range(1, 14):
stats = zonal_stats('F:/test.shp', "F:/test_2.dat", stats=['count','min', 'max', 'mean', 'std', 'percentile_50'], all_touched=False, band_num=i, nodata=0)
Here is the data: https://www.dropbox.com/sh/e8g0jwr1ci0vp2r/AAATlwU2eFjtbtMCO3R5SB1Fa?dl=0
Can you please let me know what the problem could be?