{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/rasterio/issues/663","repository_url":"https://api.github.com/repos/mapbox/rasterio","labels_url":"https://api.github.com/repos/mapbox/rasterio/issues/663/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/rasterio/issues/663/comments","events_url":"https://api.github.com/repos/mapbox/rasterio/issues/663/events","html_url":"https://github.com/mapbox/rasterio/issues/663","id":147866013,"number":663,"title":"Add keyword argument for get_data_window for 'aggressive' window pruning","user":{"login":"grovduck","id":1706997,"avatar_url":"https://avatars.githubusercontent.com/u/1706997?v=3","gravatar_id":"","url":"https://api.github.com/users/grovduck","html_url":"https://github.com/grovduck","followers_url":"https://api.github.com/users/grovduck/followers","following_url":"https://api.github.com/users/grovduck/following{/other_user}","gists_url":"https://api.github.com/users/grovduck/gists{/gist_id}","starred_url":"https://api.github.com/users/grovduck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grovduck/subscriptions","organizations_url":"https://api.github.com/users/grovduck/orgs","repos_url":"https://api.github.com/users/grovduck/repos","events_url":"https://api.github.com/users/grovduck/events{/privacy}","received_events_url":"https://api.github.com/users/grovduck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-12T20:36:35Z","updated_at":"2016-04-19T11:21:47Z","closed_at":null,"body":"I was hoping to add a simple keyword parameter to `rasterio.window.get_data_window` to return the minimum window if any of the \"bands\" are masked.  If I'm not mistaken, currently the default behavior is to return the minimum window where any of the bands is unmasked.  Maybe something like this:\r\n\r\n    def get_data_window(arr, nodata=None, all_masked=False):\r\n        \"\"\"\r\n        all_masked : bool\r\n            If False (default), returned window will include pixels that are non-masked in any band.\r\n            If True, returned window will include pixels that are non-masked in all bands.\r\n        \"\"\"\r\n        ...\r\n        if num_dims == 2:\r\n            data_rows, data_cols = np.where(arr.mask == False)\r\n        else:\r\n            f = np.all if all_masked else np.any\r\n            data_rows, data_cols = np.where(\r\n                f(np.rollaxis(arr.mask, 0, 3) == False, axis=2)\r\n            )\r\n        ...\r\n\r\n(I realize I'm being a pain with all these issues recently ... I really appreciate how much time y'all are putting into resolving issues.)"},"comment":{"url":"https://api.github.com/repos/mapbox/rasterio/issues/comments/211865878","html_url":"https://github.com/mapbox/rasterio/issues/663#issuecomment-211865878","issue_url":"https://api.github.com/repos/mapbox/rasterio/issues/663","id":211865878,"user":{"login":"perrygeo","id":1151287,"avatar_url":"https://avatars.githubusercontent.com/u/1151287?v=3","gravatar_id":"","url":"https://api.github.com/users/perrygeo","html_url":"https://github.com/perrygeo","followers_url":"https://api.github.com/users/perrygeo/followers","following_url":"https://api.github.com/users/perrygeo/following{/other_user}","gists_url":"https://api.github.com/users/perrygeo/gists{/gist_id}","starred_url":"https://api.github.com/users/perrygeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perrygeo/subscriptions","organizations_url":"https://api.github.com/users/perrygeo/orgs","repos_url":"https://api.github.com/users/perrygeo/repos","events_url":"https://api.github.com/users/perrygeo/events{/privacy}","received_events_url":"https://api.github.com/users/perrygeo/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T11:21:47Z","updated_at":"2016-04-19T11:21:47Z","body":"> calling get_data_window 3x\r\ncalling it 3 times, but with 1/3 of the data (operating on each band independently) so there shouldn't be much of a performance difference."}}