0

I am working on a Jupyter Notebook where I have a numpy.stack of raster files with values between -1 and +1, which shape is as follows:

files.shape
(2, 766, 1398)

I am ploting one of them with:

plt.imshow(files[0], cmap="RdYlGn")

My objective is to ask the user to click somewhere in the image displayed with matplotlib. When doing so, I want to store the array coordinates of the click event so that I can extract the pixel value at that location using:

 values = files.sample(zip(Xc, Yc))

Looking for previous posts on this forum I found Store mouse click event coordinates with matplotlib but I am not managing to implement the proposed example.

Any help on this?

GCGM
  • 901
  • 1
  • 17
  • 38
  • What do you mean by "not managing to implement the proposed example"? Can you copy that code and run it? Or not? What's the problem? – ImportanceOfBeingErnest Oct 08 '19 at 15:10
  • When I copy that code in my Jupyter Notebook and try to make it work with the example they provide, I cannot manage the get the list of coordinates. The `coords` variable remains empty even after doing more than 2 clicks, which is the limit they put. I have tried to adapt their suggestion to my case but not working neither – GCGM Oct 08 '19 at 15:15
  • Ok, so don't mix things up. First step is to get the solution from the other post working; as long as it doesn't work for you there is no point in adapting it to your case. – ImportanceOfBeingErnest Oct 08 '19 at 15:23
  • As I am trying to get the coords using a raster array and not a plot I think my case is different as the one in the example. I want to know if that same approach would work and how. Trying to adapt it but not getting any result – GCGM Oct 09 '19 at 05:50

0 Answers0