I have features selected on the mapcanvas. I want to perform convex hull for those selected features and save those in a memory or store it in a variable preferably and then want to do buffer for the resultant convex hull using python in QGIS.
layer = iface.activeLayer()
features = layer.selectedFeatures()
convex_hull = QgsGeometryAnalyzer().convexHull(layer, path.shp, True, -1, p-None)
The above convexhull function exports the result to a layer but doesnt store. How this can be done?
Best Answer
This code works well. I used it with a point shapefile (Multi Part) for getting its convexHull Polygon.
Before running the code in the Python Console (selected features in default yellow color):
After running the code:
Convexhull is a memory layer and it can be saved as shapefile in the directory that you prefer or be used to do a buffer in the same script. Automatically, convexhull becomes the active layer.