QgsFeature feature; //Create a point geometry with coordinates (x,y) QgsPointXY point(x, y); //Set the geometry of the feature to the point feature.setGeometry(point);
QgsFeature feature; //Create a list of points to define the polygon QgsPolygon polygon; polygon.append(QgsPointXY(x1, y1)); polygon.append(QgsPointXY(x2, y2)); polygon.append(QgsPointXY(x3, y3)); //Set the geometry of the feature to the polygon feature.setGeometry(polygon);In the above examples, we are using QgsFeature setGeometry() method to set the geometry of a feature. The first example sets the geometry of the feature to a point, by creating a QgsPointXY object and using it with setGeometry() method. The second example sets the geometry of the feature to a polygon, by creating a list of points and appending them to a QgsPolygon object, then using it with setGeometry() method. These examples indicate the usage of QGIS package library.