Skip to main content
deleted 2 characters in body
Source Link
zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)
zonalstats.calculateStatistics(None)

calculates by default just Count, Sum and Mean (as you can tell from Raster -> Zonal Statistics in QGIS Desktop, it can do a lot more).

If you, for instance, want to compute just the Mean you have to use:

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer, rasterfile, QgsZonalStatistics.Mean())
zonalstats.calculateStatistics(None)

see API for all options.

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)
zonalstats.calculateStatistics(None)

calculates by default just Count, Sum and Mean (as you can tell from Raster -> Zonal Statistics in QGIS Desktop, it can do a lot more).

If you, for instance, want to compute just the Mean you have to use:

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer, rasterfile, QgsZonalStatistics.Mean())
zonalstats.calculateStatistics(None)

see API for all options.

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)
zonalstats.calculateStatistics(None)

calculates by default just Count, Sum and Mean (as you can tell from Raster -> Zonal Statistics in QGIS Desktop, it can do a lot more).

If you, for instance, want to compute just the Mean you have to use:

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer, rasterfile, QgsZonalStatistics.Mean)
zonalstats.calculateStatistics(None)

see API for all options.

added 2 characters in body
Source Link
zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)
zonalstats.calculateStatistics(None)

calculates by default just Count, Sum and Mean (as you can tell from Raster -> Zonal Statistics in QGIS Desktop, it can do a lot more).

If you, for instance, want to compute just the Mean you have to use:

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer, rasterfile, QgsZonalStatistics.Mean())
zonalstats.calculateStatistics(None)

see API for all options.

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)
zonalstats.calculateStatistics(None)

calculates by default just Count, Sum and Mean (as you can tell from Raster -> Zonal Statistics in QGIS Desktop, it can do a lot more).

If you, for instance, want to compute just the Mean you have to use:

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer, rasterfile, QgsZonalStatistics.Mean)
zonalstats.calculateStatistics(None)

see API for all options.

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)
zonalstats.calculateStatistics(None)

calculates by default just Count, Sum and Mean (as you can tell from Raster -> Zonal Statistics in QGIS Desktop, it can do a lot more).

If you, for instance, want to compute just the Mean you have to use:

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer, rasterfile, QgsZonalStatistics.Mean())
zonalstats.calculateStatistics(None)

see API for all options.

Source Link

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer,rasterfile)
zonalstats.calculateStatistics(None)

calculates by default just Count, Sum and Mean (as you can tell from Raster -> Zonal Statistics in QGIS Desktop, it can do a lot more).

If you, for instance, want to compute just the Mean you have to use:

zonalstats = qgis.analysis.QgsZonalStatistics(vectorlayer, rasterfile, QgsZonalStatistics.Mean)
zonalstats.calculateStatistics(None)

see API for all options.