I am starting to learn PyQGIS and following tutorials online. However, I have QGIS 3.0 and most of the tutorials use QGIS version 2. I am trying to do a buffer on a point shapefile, but only have the code for Qgis 2. I have looked at the backwards incompatible changes (https://qgis.org/api/api_break.html) but cannot work out how to adjust the code. The 'GeometryAnalyzer' class, which contained the buffer function in Qgis 2 no longer exists, so I am not sure where to find it now. I am sure there is a simple solution..

The code for Qgis 2 as far as I know is as follows:

from qgis.analysis import QgsGeometryAnalzer
layer = iface.activeLayer()
QgsGeometryAnalyzer().buffer(layer, 'OutputFilePath/FileName.shp', 0.5, False, False, -1)

How can this be adjusted to Qgis 3?

1 Answer 1


The API changes page says:

QgsGeometryAnalyzer. Use the equivalent Processing algorithms instead.

processing.algorithmHelp("native:buffer") gives

processing.run('native:buffer', {"INPUT": lineLayer, "DISTANCE": 5, "OUTPUT": resultLayer})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.