xarray-contrib/xoak

Getting row, col in input data array coorespointing to selection (nearest point)

Opened this issue · 2 comments

Just found xoak which sounds like great tool. This so maybe silly question, but I am wondering if there is a way of not only returning the closest data value in the input array (let's say it is two dimensional), but also the row and column corresponding to the selected point(s). in my application, I'd like to change the value of that point so I need someway to access it.

Thanks
Axel

Hi @axelschweiger (sorry for the long wait!),

I'm thinking about two ways where you can get the array position indices:

  • When doing ds_out = ds_in.xoal.sel(...), the coordinates in ds_out are aligned with the corresponding coordinates in ds_in so I guess you could use that to retrieve the indices
  • Use directly the API of the underlying index objects (scipy, scikit-learn, s2index)

It would be useful to have a convenient way to do that, although I'm not sure how look like the API. Perhaps a simple use-case example would help?