I am using the rasterstats python package for calculating the zonal statistics of vector geometries with a raster layer like this:
stats = zonal_stats('tests/data/polygons.shp', 'tests/data/slope.tif',stats="count", all_touched=true)
Is it possible to calculate the weighted mean of the pixels like: if a pixel has an overlap 50 % with the shape then it gets a weight of 0.5 and if the pixel lies fully within the polygon it gets weight 1.