I want to compute the mean value per polygon, as well as the number of raster pixels that contributed to that calculation. I think rasterstats gives you the number of contributing pixels with their 'count' statistic.
I'm not sure how to get that with the GDAL code, though. I first thought that's what their 'numpoints' variable was counting, but their numpoints corresponds to the number of points within a ring, and I think that means the number of vertices of the ring (please correct me if I'm wrong).
Can anyone explain how to compute the number of raster pixels contributing to the GDAL cookbook calculation? Counting the number of pixels of their 'zoneraster' array variable doesn't come close to agreeing with the rasterstats count, either.