I have a vector layer which is consists of channels in a watershed. I want to rasterize each individual line in the layer separately in PyQGIS. I could not manage to loop through in the layer and rasterize. I am trying to do it with gdal:rasterize. I have seen that one can add -where in gdal:rasterize but I still couldn't make it work.
How can I do it?
My goal is to rasterize a channel and use native:rasterlayerzonalstats to get the max for each channel in the layer. Another option is buffering the line layer but I want to rasterize and go that way.
for feat in vlyr_ger.getFeatures():
objectid = feat['OBJECTID']
res88 = processing.run ("gdal:rasterize", {
'INPUT': vlyr_ger, # already vector layer
'WHERE': 'OBJECTID='+ str(objectid),
'FIELD': None,
'BURN': 1, # Fixed value to burn
'UNITS': 1, # Georeferenced units
'WIDTH': cellsize,
'HEIGHT': cellsize,
'EXTENT': rlyr_demFilled,
'NODATA': 0,
'OPTIONS': '',
'DATA_TYPE': 5, # Float32
'INIT': None,
'INVERT': False,
'EXTRA': '-tap',
'OUTPUT': 'TEMPORARY_OUTPUT'})