I have a point, which has map (canvas) coordinates and it would be great to have his screen position. I need this for setting cursor position in the same place, where point is located.
Do you know any way to convert this coordinates?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
I think something like the following could work in which you need to transform your map coordinates into screen coordinates using QgsMapTool::toCanvasCoordinates. Select a point in your layer then run the following in the Python Console:
from qgis.gui import QgsMapTool from PyQt4.QtGui import QCursor layer = iface.activeLayer() for f in layer.selectedFeatures(): geom = f.geometry() point = QgsMapTool(iface.mapCanvas()).toCanvasCoordinates(geom.asPoint()) transformed_point = iface.mapCanvas().mapToGlobal(point) QCursor().setPos(transformed_point.x(), transformed_point.y())