0

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.

Vince
  • 20,017
  • 15
  • 45
  • 64
Esra
  • 1
  • There is no mention in https://gdal.org/programs/gdal_rasterize.html that -a parameter could be repeated: -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
  • 1
    It sounds like you're trying to generate a multiband raster in one step, try creating each band one at a time then have a read of https://gis.stackexchange.com/questions/223910/using-rasterio-or-gdal-to-stack-multiple-bands-without-using-subprocess-commands/223920 about stacking up the bands into a multiband image. – Michael Stimson Jun 17 '20 at 00:36

0 Answers0