html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/3160#issuecomment-514852985,https://api.github.com/repos/pydata/xarray/issues/3160,514852985,MDEyOklzc3VlQ29tbWVudDUxNDg1Mjk4NQ==,1217238,2019-07-25T00:58:12Z,2019-07-25T00:58:12Z,MEMBER,"In fact, this was already asked on StackOverflow :) https://stackoverflow.com/questions/40179593/how-to-get-the-coordinates-of-the-maximum-in-xarray I'm going to close this, but feel free to comment or reopen if you have any further questions.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,472247188 https://github.com/pydata/xarray/issues/3160#issuecomment-514619297,https://api.github.com/repos/pydata/xarray/issues/3160,514619297,MDEyOklzc3VlQ29tbWVudDUxNDYxOTI5Nw==,35968931,2019-07-24T12:52:58Z,2019-07-24T12:52:58Z,MEMBER,"There might be a better way, but I think this is one way: First mask out all the data that isn't in your lat/long box. If your latitude and longitude are 1D then you could use `.sel()`, otherwise use `.where()`. You have two conditions (one for latitude and one for longitude), so combine them with `np.logical_and()`: ```python condition = np.logical_and(data.lat > 10.0, data.lon < 50.0) box = data.where(condition) ``` Then use `DataArray.argmax()` across all the dimensions of the result to find the indices of the maximum values. ```python inds_of_max = box.argmax(dims=['lat', 'lon']) ``` Pass those indices to your latitude/longitude coordinate arrays to get the (lat, lon) pair you want. ```python lat, lon = data.lat[inds_of_max], data.lon[inds_of_max] ``` (This would probably be better placed on stackoverflow than here but doesn't matter)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,472247188