I have a vector tile layer in QGIS, loaded from: https://cdn.kadastr.live/tiles/maps/kadastr/land_polygons/{z}/{x}/{y}.pbf.
How to select a single feature of this layer by coordinates, in PyQGIS?
I am trying to use selectByGeometry method, but it is not working.
latitude = 48.23117391
longitude = 22.74110528
layer = iface.activeLayer()
iface.mapCanvas().refresh()
geom = QgsGeometry.fromPointXY(QgsPointXY(longitude, latitude))
canvas = iface.mapCanvas()
context = QgsSelectionContext()
context.setScale(10000)
print(layer.selectedFeatureCount())
layer.selectByGeometry(geom,context)#,context,behavior= Qgis.SelectBehavior.AddToSelection,relationship= Qgis.SelectGeometryRelationship.Intersect,flags=Qgis.SelectionFlags(2))
print(layer.selectedFeatureCount())


pt_geom = QgsGeometry().fromWkt(g.asWkt())? – Стьопа Брич Sep 25 '23 at 17:53geomis not modified. – Ben W Sep 26 '23 at 10:35bool isPointOrRectangle– Taras Nov 22 '23 at 09:52QgsGeometry(g)also creates a copy of a geometry and will be more efficient because it saves on a roundtrip through WKT. – bugmenot123 Nov 22 '23 at 11:29