{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/regions/issues/87","repository_url":"https://api.github.com/repos/astropy/regions","labels_url":"https://api.github.com/repos/astropy/regions/issues/87/labels{/name}","comments_url":"https://api.github.com/repos/astropy/regions/issues/87/comments","events_url":"https://api.github.com/repos/astropy/regions/issues/87/events","html_url":"https://github.com/astropy/regions/pull/87","id":192575778,"number":87,"title":"Added initial implementation of Polygon to_mask and as_patch","user":{"login":"astrofrog","id":314716,"avatar_url":"https://avatars.githubusercontent.com/u/314716?v=3","gravatar_id":"","url":"https://api.github.com/users/astrofrog","html_url":"https://github.com/astrofrog","followers_url":"https://api.github.com/users/astrofrog/followers","following_url":"https://api.github.com/users/astrofrog/following{/other_user}","gists_url":"https://api.github.com/users/astrofrog/gists{/gist_id}","starred_url":"https://api.github.com/users/astrofrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astrofrog/subscriptions","organizations_url":"https://api.github.com/users/astrofrog/orgs","repos_url":"https://api.github.com/users/astrofrog/repos","events_url":"https://api.github.com/users/astrofrog/events{/privacy}","received_events_url":"https://api.github.com/users/astrofrog/received_events","type":"User","site_admin":false},"labels":[{"id":212048367,"url":"https://api.github.com/repos/astropy/regions/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"assignees":[{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/astropy/regions/milestones/4","html_url":"https://github.com/astropy/regions/milestones/0.2","labels_url":"https://api.github.com/repos/astropy/regions/milestones/4/labels","id":1848735,"number":4,"title":"0.2","description":"","creator":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":14,"state":"open","created_at":"2016-06-26T12:01:51Z","updated_at":"2016-11-30T21:47:53Z","due_on":"2016-12-05T00:00:00Z","closed_at":null},"comments":16,"created_at":"2016-11-30T14:14:06Z","updated_at":"2016-11-30T21:57:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/astropy/regions/pulls/87","html_url":"https://github.com/astropy/regions/pull/87","diff_url":"https://github.com/astropy/regions/pull/87.diff","patch_url":"https://github.com/astropy/regions/pull/87.patch"},"body":"This implements to_mask for Polygon in line with other shapes.\r\n\r\nIt does not use code from ginga for example - I did look at that code, but the issue is we need to be able to efficiently compute the sub-pixel overlap without making large arrays of pixels (the ginga code operates with vectorized operations on Numpy arrays).\r\n\r\nHowever, the code I'm adding here for the point/polygon stuff is pretty lightweight. Example usage:\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom regions import PolygonPixelRegion, PixCoord\r\n\r\nvx = np.array([-3, 5, 2, 0.5, -1]).astype(float)\r\nvy = np.array([-2., -3., 4., 2., 3.]).astype(float)\r\n\r\nvertices = PixCoord(vx, vy)\r\n\r\nregion = PolygonPixelRegion(vertices)\r\n\r\nmask = region.to_mask(mode='subpixels', subpixels=10)\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(1, 1, 1)\r\nax.imshow(mask, cmap=plt.cm.viridis, origin='lower',\r\n          interpolation='nearest',\r\n          extent=mask.bbox.extent)\r\nax.add_patch(region.as_patch(edgecolor='white', facecolor='none'))\r\nfig.savefig('polygon.png')\r\n```\r\n\r\n![polygon](https://cloud.githubusercontent.com/assets/314716/20755404/c2a059e8-b706-11e6-8afc-4fdd09c2cfa7.png)\r\n\r\nThis needs tests of course, but waiting first to see if people are open to this.\r\n"},"comment":{"url":"https://api.github.com/repos/astropy/regions/issues/comments/264008651","html_url":"https://github.com/astropy/regions/pull/87#issuecomment-264008651","issue_url":"https://api.github.com/repos/astropy/regions/issues/87","id":264008651,"user":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T21:57:39Z","updated_at":"2016-11-30T21:57:39Z","body":"+1 to merge and add more tests / docs in the coming days."}}
{"actor":{"display_login":"cdeil"}}