Does anyone know how I can get the coordinate value displayed at the buttom of the qgis window? I have been searching through the qgis api but am not able to find anything suitable..
Asked
Active
Viewed 585 times
2
-
1seems to me this question has been asked 1000 times ... "clicked coordinates qgis python" in google led me to several answers of gis.stack exchange ... – Snaileater Mar 07 '19 at 16:44
1 Answers
3
this code is a simple example for access to cursor coordinates:
def canvasMoveEvent(event):
x = event.pos().x()
y = event.pos().y()
point = canvas.getCoordinateTransform().toMapCoordinates(x, y)
print ('({:.4f}, {:.4f})'.format(point[0], point[1]))
from qgis.gui import QgsMapToolEmitPoint
canvas = iface.mapCanvas()
pointTool = QgsMapToolEmitPoint(canvas)
pointTool.canvasMoveEvent = canvasMoveEvent
canvas.setMapTool( pointTool )
I hope it helps you
Fran Raga
- 7,838
- 3
- 26
- 47