How to make a raster with values that are the sum of all points inside each raster cell?
The burn value is a specific attribute.
Using gdal_rasterize or gdal.RasterizeLayer(), the resulting raster only has the value of a random (or probably the first or last) point inside a raster cell. I’ve already tried gdal_rasterize option ALL_TOUCHED, but it does not change the behaviour.
Answer
Adding 'MERGE_ALG=ADD' to the list of options to gdal.RasterizeLayer() did the trick, thanks to kyle. An example:
gdal.RasterizeLayer(target_ds, [1], src_layer, options = ['MERGE_ALG=ADD'])
This is documented in http://www.gdal.org/gdal__alg_8h.html.
No comments:
Post a Comment