2

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..

Ending
  • 555
  • 2
  • 13
  • 1
    seems 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 Answers1

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