I want to calculate zonal stats of a raster using a polygon layer and the filter the ouput as another layer.
This is the code I tried:
zoneStat = QgsZonalStatistics (tempVectorLyr, rasterLyr, '-', 1)
zoneStat.calculateStatistics(None)
count = math.ceil(thresholdArea / (abs(xres) * abs(yres)))
features = zoneStat.getFeatures("\"_sum\">{}".format(count))
featureLayer = QgsVectorLayer("Polygon", "Flayer", "memory")
featureLayer.setCrs(r_crs)
pr = featureLayer.dataProvider()
no_f = 0
for feature in features:
no_f = no_f + 1
pr.addFeature(feature)
This was the error I got:
AttributeError: 'QgsZonalStatistics' object has no attribute 'getFeatures'
I'm guessing zoneStat is not a layer, how do I save it as memory layer?