point = QgsGeometry.fromPointXY(QgsPointXY(10, 20))
layer = QgsVectorLayer('Point', 'Points', 'memory') fields = QgsFields() fields.append(QgsField('ID', QVariant.Int)) layer.dataProvider().addAttributes(fields) coords = [(10, 20), (30, 40), (50, 60)] for i, coord in enumerate(coords): point = QgsGeometry.fromPointXY(QgsPointXY(coord[0], coord[1])) feature = QgsFeature() feature.setGeometry(point) feature.setAttributes([i]) layer.dataProvider().addFeature(feature) QgsProject.instance().addMapLayer(layer)In this example, a new memory layer is created and points are added to it based on a list of coordinates. Each point is given a unique ID value and added as a feature to the layer. Overall, the QgsGeometry class is a useful tool for working with GIS data in Python and the fromPointXY() method is just one example of how it can be used to create and manipulate different types of geometries.