Getting row, col in input data array coorespointing to selection (nearest point)
Opened this issue · 2 comments
axelschweiger commented
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
benbovy commented
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 inds_out
are aligned with the corresponding coordinates inds_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?
axelschweiger commented
Benoit
Thanks for the answer. I’m in the middle of getting ready for a lengthy trip so won’t have time to get a “use-case” example together until later the summer. Will try then.
Axel
From: Benoit Bovy ***@***.***>
Sent: Friday, May 26, 2023 07:01
To: xarray-contrib/xoak ***@***.***>
Cc: Axel J Schweiger ***@***.***>; Mention ***@***.***>
Subject: Re: [xarray-contrib/xoak] Getting row, col in input data array coorespointing to selection (nearest point) (Issue #42)
Hi @axelschweiger<https://urldefense.com/v3/__https:/github.com/axelschweiger__;!!K-Hz7m0Vt54!gi-_JcyIDlTs66K-guIkoFNajimq9X5zZgTbkzYeOA75a-lNxsCqvMHQIJedwIgEwnnlij2-3y5pcc6mfmQFET4$> (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?
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https:/github.com/xarray-contrib/xoak/issues/42*issuecomment-1564440430__;Iw!!K-Hz7m0Vt54!gi-_JcyIDlTs66K-guIkoFNajimq9X5zZgTbkzYeOA75a-lNxsCqvMHQIJedwIgEwnnlij2-3y5pcc6mOeqWumU$>, or unsubscribe<https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ALJTXMJIHXJVAASOBTEJYULXICZSNANCNFSM6AAAAAAU3ZTEHU__;!!K-Hz7m0Vt54!gi-_JcyIDlTs66K-guIkoFNajimq9X5zZgTbkzYeOA75a-lNxsCqvMHQIJedwIgEwnnlij2-3y5pcc6m8ju86Ro$>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>