I am using rasterio to convert a geopandas dataframe of points to a geotif raster. For that I am using this python code:
with rasterio.open("somepath/rasterized.tif", 'w+', **meta) as out:
out.nodata = 0
out_arr = out.read(1)
# this is where we create a generator of geom, value pairs to use in rasterizing
shapes = ((geom, value * 2) for geom, value in zip(gdf.geometry, gdf["PositionConfidence"]))
burned = features.rasterize(shapes=shapes, fill=0, out=out_arr, transform=out.transform)
out.write_band(1, burned)
out.write_band(2, burned)
out.write_band(3, burned)
out_arr1 = out.read(1)
The code not only writes a fixed value to the raster but a value based on the point to be converted.
The problem is that there are many points per raster pixel. Using above approach only a single points value is burned to the pixel. What I am looking for is having the average of all points values per pixel burned to the given pixel.
Thanks for your help