from qgis.core import QgsGeometry # create a point at x=0, y=0 point = QgsGeometry.fromPointXY(QgsPointXY(0, 0)) # or create a point from a WKT string point = QgsGeometry.fromWkt('POINT(0 0)')
from qgis.core import QgsGeometry # create a line with two points: (0,0) and (1,1) line = QgsGeometry.fromPolylineXY([QgsPointXY(0, 0), QgsPointXY(1, 1)]) # or create a line from a WKT string line = QgsGeometry.fromWkt('LINESTRING(0 0, 1 1)')
from qgis.core import QgsGeometry # create buffered polygon around a point point = QgsGeometry.fromPointXY(QgsPointXY(0, 0)) buffer = point.buffer(1.0, 5) # check if a point is within the buffered area another_point = QgsGeometry.fromPointXY(QgsPointXY(0.5, 0.5)) if another_point.intersects(buffer): print('The point is within the buffer')In these examples, the qgis.core package library is used to create point and line geometries, as well as perform a spatial query using buffer and intersection operations.