id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 753874419,MDU6SXNzdWU3NTM4NzQ0MTk=,4630,".sel(...., method='nearest') fails for large requests. ",44210245,closed,0,,,8,2020-11-30T23:20:18Z,2021-02-16T23:37:29Z,2021-02-16T23:37:29Z,CONTRIBUTOR,,,,"A common usage of `xarray` is to retrieve climate model data from the grid cells closest to a weather station. That might look like this ``` import xarray as xr import numpy as np ds = xr.tutorial.open_dataset(""air_temperature"") # Define taget latitude and longitude tgt_lat = np.linspace(0, 100, num=10) tgt_lon = np.linspace(0, 100, num=10) # Retrieve data at target latitude and longitude tgt_data = ds['air'].sel(lon=tgt_lon, lat=tgt_lat, method='nearest') ``` My problem is that I am trying subset `ds` to 10 points in space (which is the length of tgt_lat and tgt_lon), but in fact `xarray` retrieves 100 points (10 latitude by 10 longitude). I can get around this by calling `tgt_data = tgt_data.values.diagonal()`. But this results in a non-xarray object. Furthermore, if instead of querying for 10 points in space, I query for 10,000, I run out of memory because `xarray` retrieves 100,000,000 points in space (10,000^2). Is there a way to only retrieve the diagonal elements? If not, is this something that should be added? ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4630/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue