# combine geometries into a single multi-polygon geometry multi_polygon = QgsGeometry.combine([polygon1, polygon2])
Example 2:
Let's say you have a line and a point geometry and you want to combine them into a single multi-geometry object:
from qgis.core import QgsGeometry
# create a line and a point geometry line = QgsGeometry.fromWkt('LINESTRING(0 0,10 10)') point = QgsGeometry.fromWkt('POINT(20 20)')
# combine geometries into a single multi-geometry object multi_geometry = QgsGeometry.combine([line, point])
This code example uses the python qgis.core library.
Python QgsGeometry.combine - 57 examples found. These are the top rated real world Python examples of qgis.core.QgsGeometry.combine extracted from open source projects. You can rate examples to help us improve the quality of examples.