{"action":"created","issue":{"url":"https://api.github.com/repos/xray/xray/issues/644","labels_url":"https://api.github.com/repos/xray/xray/issues/644/labels{/name}","comments_url":"https://api.github.com/repos/xray/xray/issues/644/comments","events_url":"https://api.github.com/repos/xray/xray/issues/644/events","html_url":"https://github.com/xray/xray/issues/644","id":114773593,"number":644,"title":"Feature request: only allow nearest-neighbor .sel for valid data (not NaN positions)","user":{"login":"chrwerner","id":13906519,"avatar_url":"https://avatars.githubusercontent.com/u/13906519?v=3","gravatar_id":"","url":"https://api.github.com/users/chrwerner","html_url":"https://github.com/chrwerner","followers_url":"https://api.github.com/users/chrwerner/followers","following_url":"https://api.github.com/users/chrwerner/following{/other_user}","gists_url":"https://api.github.com/users/chrwerner/gists{/gist_id}","starred_url":"https://api.github.com/users/chrwerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrwerner/subscriptions","organizations_url":"https://api.github.com/users/chrwerner/orgs","repos_url":"https://api.github.com/users/chrwerner/repos","events_url":"https://api.github.com/users/chrwerner/events{/privacy}","received_events_url":"https://api.github.com/users/chrwerner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-03T09:17:21Z","updated_at":"2015-11-11T00:27:10Z","closed_at":null,"body":"Hi.\r\n\r\nMaybe I'm missing something, but I'm trying to get data by providing lat & lon coordinates to the .sel operator together with the nearest argument. This works, but in my case often ocean pixels are nearby and those contain NaN. Is there a way to only return the nearest _valid_ point even if this is a bit further away then the invalid locations?\r\n\r\nChristian"},"comment":{"url":"https://api.github.com/repos/xray/xray/issues/comments/155611625","html_url":"https://github.com/xray/xray/issues/644#issuecomment-155611625","issue_url":"https://api.github.com/repos/xray/xray/issues/644","id":155611625,"user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"created_at":"2015-11-11T00:27:10Z","updated_at":"2015-11-11T00:27:10Z","body":"This is tricky to put into `.sel` because that method currently works by only looking at coordinate labels, not at data values.\r\n\r\nOne way to fix this would be to unravel your two dimensions corresponding to latitude and longitude into a single \"lat_lon\" dimension. At this point, you could apply a sea mask, to produce a compressed lat_lon coordinate corresponding to only unmasked points. Now, it's relatively straightforward to imagine doing nearest neighbor lookups on this set of labels.\r\n\r\nThis later solution will require a few steps (all of which are on the \"to do\" list, but without any immediate timelines):\r\n1. support for multi-level indexes in xray\r\n2. support for \"unraveling\" multiple dimensions into 1-dimension\r\n3. support for looking up nearest locations in multiple dimensions via some sort of spatial index (e.g., a KD tree)"}}