Skip to main content
added 30 characters in body
Source Link

Here's my solution which I derived from running through the Zonal Statistics plugin wizard and selectingviewing the generated Python command with Advanced -> ViewCopy as Python Code SnippetCommand. Then simply adding a loop to support the multiband requirement.

for i in range(1,num_raster_bands):
    processing.run("native:zonalstatisticsfb", { 
        'INPUT':'my_shp_file',
        'INPUT_RASTER':'my_raster_file',
        'RASTER_BAND':i,
        'COLUMN_PREFIX':'_',
        'STATISTICS':[0,1,2],
        'OUTPUT':f'output_filepath_{i}.csv'
})

Here's my solution which I derived from running through the Zonal Statistics plugin wizard and selecting Advanced -> View Python Code Snippet

for i in range(1,num_raster_bands):
    processing.run("native:zonalstatisticsfb", { 
        'INPUT':'my_shp_file',
        'INPUT_RASTER':'my_raster_file',
        'RASTER_BAND':i,
        'COLUMN_PREFIX':'_',
        'STATISTICS':[0,1,2],
        'OUTPUT':f'output_filepath_{i}.csv'
})

Here's my solution which I derived from running through the Zonal Statistics plugin wizard and viewing the generated Python command with Advanced -> Copy as Python Command. Then simply adding a loop to support the multiband requirement.

for i in range(1,num_raster_bands):
    processing.run("native:zonalstatisticsfb", { 
        'INPUT':'my_shp_file',
        'INPUT_RASTER':'my_raster_file',
        'RASTER_BAND':i,
        'COLUMN_PREFIX':'_',
        'STATISTICS':[0,1,2],
        'OUTPUT':f'output_filepath_{i}.csv'
})
Source Link

Here's my solution which I derived from running through the Zonal Statistics plugin wizard and selecting Advanced -> View Python Code Snippet

for i in range(1,num_raster_bands):
    processing.run("native:zonalstatisticsfb", { 
        'INPUT':'my_shp_file',
        'INPUT_RASTER':'my_raster_file',
        'RASTER_BAND':i,
        'COLUMN_PREFIX':'_',
        'STATISTICS':[0,1,2],
        'OUTPUT':f'output_filepath_{i}.csv'
})