I have a shapefile consisting of polygon geometries, each row/geometry associated with multiple attributes. I want to generate a raster file with multiple bands, where each band will have a different burn in value using a different attribute.
I can successfully generate a single banded raster using the command below:
gdal_rasterize -l grid_polygon_attributes -a attribute_1 -tr x_res y_res -a_nodata -99.0 -te xmin xmax ymin ymax -ot Float32 -of GTiff "in.shp" "out.tif"
I could not manage to do it for multiple bands associated with multiple attributes [the following does not work]
gdal_rasterize -l grid_polygon_attributes -b 1 -b2 -a attribute_1 -a attribute_2 -tr x_res y_res -a_nodata -99.0 -te xmin xmax ymin ymax -ot Float32 -of GTiff "in.shp" "out.tif"
ALSO: It will be great if I can also do this in Python - I tried using osgeo.gdal.Rasterize() with no luck.
-a <attribute_name> Identifies an attribute field on the features to be used for a burn-in value. The value will be burned into all output bands.I think that you must burn each attribute into separate image first and collect them into a multiband raster as a final step. – user30184 Jun 16 '20 at 22:56