Jonathan Kowalik
Jonathan Kowalik

Reputation: 151

Interactively get readable(i.e. lng/lat) coordinates from a matplotlib basemap plot?

I'm doing matplotlib basemap plots. The current coordinates of the mouse pointer are interactively displayed in the lower right area of the figure. But they are in map coordinates (I assume). I would like to have them in lng/lat.

Is there a quick way to do this? Do I have to dive into mouse events (which I'm not familiar with yet)?

Upvotes: 1

Views: 1046

Answers (1)

Jonathan Kowalik
Jonathan Kowalik

Reputation: 151

tcaswell pointed me in the exactly right direction:

ax = plt.gca()
def format_coord(x, y):
    return 'x=%.4f, y=%.4f'%(m(x, y, inverse = True))
ax.format_coord = format_coord

This does what I wanted.

Upvotes: 4

Related Questions