{"action":"created","issue":{"url":"https://api.github.com/repos/Toblerity/Shapely/issues/495","repository_url":"https://api.github.com/repos/Toblerity/Shapely","labels_url":"https://api.github.com/repos/Toblerity/Shapely/issues/495/labels{/name}","comments_url":"https://api.github.com/repos/Toblerity/Shapely/issues/495/comments","events_url":"https://api.github.com/repos/Toblerity/Shapely/issues/495/events","html_url":"https://github.com/Toblerity/Shapely/issues/495","id":237995029,"number":495,"title":"Can not split anti-meridian crossing polygon","user":{"login":"bbuechler","id":1580924,"avatar_url":"https://avatars0.githubusercontent.com/u/1580924?v=3","gravatar_id":"","url":"https://api.github.com/users/bbuechler","html_url":"https://github.com/bbuechler","followers_url":"https://api.github.com/users/bbuechler/followers","following_url":"https://api.github.com/users/bbuechler/following{/other_user}","gists_url":"https://api.github.com/users/bbuechler/gists{/gist_id}","starred_url":"https://api.github.com/users/bbuechler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbuechler/subscriptions","organizations_url":"https://api.github.com/users/bbuechler/orgs","repos_url":"https://api.github.com/users/bbuechler/repos","events_url":"https://api.github.com/users/bbuechler/events{/privacy}","received_events_url":"https://api.github.com/users/bbuechler/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-22T22:47:25Z","updated_at":"2017-06-23T12:21:16Z","closed_at":"2017-06-23T12:21:16Z","body":"\r\n## Expected behavior and actual behavior.\r\n\r\nSplitting a polygon along the anti-meridian results in malformed polygons\r\n\r\n![image](https://user-images.githubusercontent.com/1580924/27457797-85509656-5752-11e7-97d0-eccb8c806c50.png)\r\n\r\nI have a polygon that crosses that anti-meridian. These granules do not render properly in our UI, so we have to split them along the anti-meridian. The result is a split granule, but it is not split along the anti-meridian.  The result appears to be the same for various permutations/variations of anti-meridians ( -180 vs 180 vs -179.99 vs 179.99 etc)\r\n\r\n## Steps to reproduce the problem.\r\n\r\n```\r\nfrom shapely import wkt\r\nfrom shapely.ops import linemerge, unary_union, polygonize\r\n\r\nPOLY = \"POLYGON ((-141.277176 -11.379341, -141.690079 -13.143938, -142.114716 -14.906811, -142.544556 -16.668859, -142.984177 -18.429907, -143.434113 -20.188940, -143.895538 -21.946619, -144.374359 -23.701473, -144.862244 -25.455635, -145.364960 -27.207277, -145.884094 -28.956835, -146.426727 -30.702225, -146.983597 -32.446487, -147.561813 -34.187397, -148.163910 -35.925583, -148.792206 -37.660553, -149.456161 -39.389980, -150.145554 -41.116703, -150.870590 -42.839054, -151.635010 -44.556057, -152.451187 -46.265881, -153.309570 -47.971203, -154.223877 -49.669815, -155.201187 -51.361019, -156.249863 -53.043583, -157.387848 -54.714783, -158.610474 -56.376122, -159.939987 -58.025070, -161.392517 -59.659386, -162.995621 -61.274456, -164.757050 -62.871429, -166.713135 -64.444458, -168.898438 -65.989197, -171.355942 -67.500839, -174.142242 -68.969604, -177.304688 -70.390717, 179.079529  -71.750107, 174.929764  -73.033142, -178.713760 -73.532257, -174.919724 -72.133804, -171.670792 -70.672295, -168.857422 -69.163040, -166.402130 -67.615784, -164.241821 -66.037704, -162.310760 -64.438416, -160.598907 -62.814171, -159.058395 -61.172050, -157.662918 -59.515087, -156.374847 -57.848759, -155.209396 -56.168194, -154.135330 -54.478321, -153.140305 -52.780083, -152.214554 -51.074577, -151.333969 -49.365730, -150.522339 -47.648273, -149.757462 -45.925396, -149.034439 -44.197948, -148.334457 -42.469131, -147.682037 -40.733524, -147.059235 -38.994305, -146.462967 -37.251698, -145.890701 -35.506409, -145.328079 -33.761124, -144.797516 -32.010731, -144.284561 -30.257998, -143.787613 -28.502935, -143.294830 -26.748104, -142.826111 -24.989393, -142.369293 -23.228861, -141.923279 -21.466860, -141.487198 -19.703259, -141.051956 -17.940372, -140.633240 -16.174145, -140.221893 -14.406814, -139.817093 -12.638653, -139.418289 -10.869822, -141.277176 -11.379341  ))\"\r\nLINE = \"LINESTRING(180 90, 180 -90)\"\r\n\r\npoly = wkt.loads(POLY)\r\nline = wkt.loads(LINE)\r\n\r\nmerged = linemerge([poly.boundary, line])\r\nborders = unary_union(merged)\r\npolygons = polygonize(borders)\r\nfor p in polygons:\r\n    print(p)\r\n\r\n```\r\nThe resulting polygons: \r\n\r\n```\r\nPOLYGON ((-171.1893902591411 -70.41404315811644, -177.304688 -70.390717, -174.142242 -68.969604, -171.355942 -67.500839, -168.898438 -65.989197, -166.713135 -64.444458, -164.75705 -62.871429, -162.995621 -61.274456, -161.392517 -59.659386, -159.939987 -58.02507, -158.610474 -56.376122, -157.387848 -54.714783, -156.249863 -53.043583, -155.201187 -51.361019, -154.223877 -49.669815, -153.30957 -47.971203, -152.451187 -46.265881, -151.63501 -44.556057, -150.87059 -42.839054, -150.145554 -41.116703, -149.456161 -39.38998, -148.792206 -37.660553, -148.16391 -35.925583, -147.561813 -34.187397, -146.983597 -32.446487, -146.426727 -30.702225, -145.884094 -28.956835, -145.36496 -27.207277, -144.862244 -25.455635, -144.374359 -23.701473, -143.895538 -21.946619, -143.434113 -20.18894, -142.984177 -18.429907, -142.544556 -16.668859, -142.114716 -14.906811, -141.690079 -13.143938, -141.277176 -11.379341, -139.418289 -10.869822, -139.817093 -12.638653, -140.221893 -14.406814, -140.63324 -16.174145, -141.051956 -17.940372, -141.487198 -19.703259, -141.923279 -21.46686, -142.369293 -23.228861, -142.826111 -24.989393, -143.29483 -26.748104, -143.787613 -28.502935, -144.284561 -30.257998, -144.797516 -32.010731, -145.328079 -33.761124, -145.890701 -35.506409, -146.462967 -37.251698, -147.059235 -38.994305, -147.682037 -40.733524, -148.334457 -42.469131, -149.034439 -44.197948, -149.757462 -45.925396, -150.522339 -47.648273, -151.333969 -49.36573, -152.214554 -51.074577, -153.140305 -52.780083, -154.13533 -54.478321, -155.209396 -56.168194, -156.374847 -57.848759, -157.662918 -59.515087, -159.058395 -61.17205, -160.598907 -62.814171, -162.31076 -64.438416, -164.241821 -66.03770400000001, -166.40213 -67.615784, -168.857422 -69.16304, -171.1893902591411 -70.41404315811644))\r\nPOLYGON ((-171.1893902591411 -70.41404315811644, 179.079529 -71.750107, 174.929764 -73.033142, -178.71376 -73.532257, -174.919724 -72.133804, -171.670792 -70.67229500000001, -171.1893902591411 -70.41404315811644))\r\n```\r\n\r\nIt looks like ops.split() might be the prefered solution, but that appears to be in version Shapely 1.6, which appears not to be available for python3 from PyPI yet. However, if I try to use split() with python 2.7 (which I can't use in production), this polygon does not split at all. I end up with just a LineString that represents the original polygon boundary. If anyone things thats is worth an issue, I can write that up also or instead. \r\n\r\n```\r\nnew_poly = split(poly.boundary, line)\r\nfor p in new_poly:\r\n    print(p)\r\n``` \r\n\r\nResult:\r\n```\r\nLINESTRING (-141.277176 -11.379341, -141.690079 -13.143938, -142.114716 -14.906811, -142.544556 -16.668859, -142.984177 -18.429907, -143.434113 -20.18894, -143.895538 -21.946619, -144.374359 -23.701473, -144.862244 -25.455635, -145.36496 -27.207277, -145.884094 -28.956835, -146.426727 -30.702225, -146.983597 -32.446487, -147.561813 -34.187397, -148.16391 -35.925583, -148.792206 -37.660553, -149.456161 -39.38998, -150.145554 -41.116703, -150.87059 -42.839054, -151.63501 -44.556057, -152.451187 -46.265881, -153.30957 -47.971203, -154.223877 -49.669815, -155.201187 -51.361019, -156.249863 -53.043583, -157.387848 -54.714783, -158.610474 -56.376122, -159.939987 -58.02507, -161.392517 -59.659386, -162.995621 -61.274456, -164.75705 -62.871429, -166.713135 -64.444458, -168.898438 -65.989197, -171.355942 -67.500839, -174.142242 -68.969604, -177.304688 -70.390717, 179.079529 -71.750107, 174.929764 -73.033142, -178.71376 -73.532257, -174.919724 -72.133804, -171.670792 -70.67229500000001, -168.857422 -69.16304, -166.40213 -67.615784, -164.241821 -66.03770400000001, -162.31076 -64.438416, -160.598907 -62.814171, -159.058395 -61.17205, -157.662918 -59.515087, -156.374847 -57.848759, -155.209396 -56.168194, -154.13533 -54.478321, -153.140305 -52.780083, -152.214554 -51.074577, -151.333969 -49.36573, -150.522339 -47.648273, -149.757462 -45.925396, -149.034439 -44.197948, -148.334457 -42.469131, -147.682037 -40.733524, -147.059235 -38.994305, -146.462967 -37.251698, -145.890701 -35.506409, -145.328079 -33.761124, -144.797516 -32.010731, -144.284561 -30.257998, -143.787613 -28.502935, -143.29483 -26.748104, -142.826111 -24.989393, -142.369293 -23.228861, -141.923279 -21.46686, -141.487198 -19.703259, -141.051956 -17.940372, -140.63324 -16.174145, -140.221893 -14.406814, -139.817093 -12.638653, -139.418289 -10.869822, -141.277176 -11.379341)\r\n``` \r\n\r\nIf I use a polygon that DOES NOT cross the anti-meridian, and an arbitrary LineString to bisect it, both methods work great.\r\n\r\n```\r\nPOLY = \"POLYGON ((-141.277176 -11.379341, -141.690079 -13.143938, -142.114716 -14.906811, -142.544556 -16.668859, -142.984177 -18.429907, -143.434113 -20.18894, -143.895538 -21.946619, -144.374359 -23.701473, -144.862244 -25.455635, -145.36496 -27.207277, -145.884094 -28.956835, -146.426727 -30.702225, -146.983597 -32.446487, -147.561813 -34.187397, -148.16391 -35.925583, -148.792206 -37.660553, -149.456161 -39.38998, -150.145554 -41.116703, -150.87059 -42.839054, -151.63501 -44.556057, -152.451187 -46.265881, -153.30957 -47.971203, -154.223877 -49.669815, -155.201187 -51.361019, -156.249863 -53.043583, -157.387848 -54.714783, -158.610474 -56.376122, -159.939987 -58.02507, -161.392517 -59.659386, -162.995621 -61.274456, -164.75705 -62.871429, -166.713135 -64.444458, -168.898438 -65.989197, -171.355942 -67.500839, -174.142242 -68.969604, -177.304688 -70.390717, -178.71376 -73.532257, -174.919724 -72.133804, -171.670792 -70.67229501, -168.857422 -69.16304, -166.40213 -67.615784, -164.241821 -66.03770401, -162.31076 -64.438416, -160.598907 -62.814171, -159.058395 -61.17205, -157.662918 -59.515087, -156.374847 -57.848759, -155.209396 -56.168194, -154.13533 -54.478321, -153.140305 -52.780083, -152.214554 -51.074577, -151.333969 -49.36573, -150.522339 -47.648273, -149.757462 -45.925396, -149.034439 -44.197948, -148.334457 -42.469131, -147.682037 -40.733524, -147.059235 -38.994305, -146.462967 -37.251698, -145.890701 -35.506409, -145.328079 -33.761124, -144.797516 -32.010731, -144.284561 -30.257998, -143.787613 -28.502935, -143.29483 -26.748104, -142.826111 -24.989393, -142.369293 -23.228861, -141.923279 -21.46686, -141.487198 -19.703259, -141.051956 -17.940372, -140.63324 -16.174145, -140.221893 -14.406814, -139.817093 -12.638653, -139.418289 -10.869822, -141.277176 -11.379341))\"\r\nLINE = \"LINESTRING(-167 -47, -130 -57)\"\r\n``` \r\n\r\nAnd both methods produce the same two derived polygons:\r\n\r\n```\r\nPOLYGON ((-154.6153280459034 -50.34720863624233, -154.223877 -49.669815, -153.30957 -47.971203, -152.451187 -46.265881, -151.63501 -44.556057, -150.87059 -42.839054, -150.145554 -41.116703, -149.456161 -39.38998, -148.792206 -37.660553, -148.16391 -35.925583, -147.561813 -34.187397, -146.983597 -32.446487, -146.426727 -30.702225, -145.884094 -28.956835, -145.36496 -27.207277, -144.862244 -25.455635, -144.374359 -23.701473, -143.895538 -21.946619, -143.434113 -20.18894, -142.984177 -18.429907, -142.544556 -16.668859, -142.114716 -14.906811, -141.690079 -13.143938, -141.277176 -11.379341, -139.418289 -10.869822, -139.817093 -12.638653, -140.221893 -14.406814, -140.63324 -16.174145, -141.051956 -17.940372, -141.487198 -19.703259, -141.923279 -21.46686, -142.369293 -23.228861, -142.826111 -24.989393, -143.29483 -26.748104, -143.787613 -28.502935, -144.284561 -30.257998, -144.797516 -32.010731, -145.328079 -33.761124, -145.890701 -35.506409, -146.462967 -37.251698, -147.059235 -38.994305, -147.682037 -40.733524, -148.334457 -42.469131, -149.034439 -44.197948, -149.757462 -45.925396, -150.522339 -47.648273, -151.333969 -49.36573, -152.1790425681784 -51.00566417076259, -154.6153280459034 -50.34720863624233))\r\nPOLYGON ((-152.1790425681784 -51.00566417076259, -152.214554 -51.074577, -153.140305 -52.780083, -154.13533 -54.478321, -155.209396 -56.168194, -156.374847 -57.848759, -157.662918 -59.515087, -159.058395 -61.17205, -160.598907 -62.814171, -162.31076 -64.438416, -164.241821 -66.03770401, -166.40213 -67.615784, -168.857422 -69.16304, -171.670792 -70.67229501, -174.919724 -72.133804, -178.71376 -73.532257, -177.304688 -70.390717, -174.142242 -68.969604, -171.355942 -67.500839, -168.898438 -65.989197, -166.713135 -64.444458, -164.75705 -62.871429, -162.995621 -61.274456, -161.392517 -59.659386, -159.939987 -58.02507, -158.610474 -56.376122, -157.387848 -54.714783, -156.249863 -53.043583, -155.201187 -51.361019, -154.6153280459034 -50.34720863624233, -152.1790425681784 -51.00566417076259))\r\n```\r\n\r\n## Operating system\r\n\r\nMac OS X 10.12.3\r\n\r\n## Shapely version and provenance\r\n\r\nPython 3.6.1, Shapely (1.5.17.post1) from pip3\r\nPython 2.7.10, Shapely (1.6b2) from pip\r\n"},"comment":{"url":"https://api.github.com/repos/Toblerity/Shapely/issues/comments/310651357","html_url":"https://github.com/Toblerity/Shapely/issues/495#issuecomment-310651357","issue_url":"https://api.github.com/repos/Toblerity/Shapely/issues/495","id":310651357,"user":{"login":"sgillies","id":33697,"avatar_url":"https://avatars1.githubusercontent.com/u/33697?v=3","gravatar_id":"","url":"https://api.github.com/users/sgillies","html_url":"https://github.com/sgillies","followers_url":"https://api.github.com/users/sgillies/followers","following_url":"https://api.github.com/users/sgillies/following{/other_user}","gists_url":"https://api.github.com/users/sgillies/gists{/gist_id}","starred_url":"https://api.github.com/users/sgillies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgillies/subscriptions","organizations_url":"https://api.github.com/users/sgillies/orgs","repos_url":"https://api.github.com/users/sgillies/repos","events_url":"https://api.github.com/users/sgillies/events{/privacy}","received_events_url":"https://api.github.com/users/sgillies/received_events","type":"User","site_admin":false},"created_at":"2017-06-23T12:21:16Z","updated_at":"2017-06-23T12:21:16Z","body":"@bbuechler Thanks for the thorough report!\r\n\r\nShapely's domain is 2-D computational geometry in a plane with no singularities like the antimeridian or poles. To use it, you'd need to transform your polygons to a coordinate reference system where the dateline is no longer a singularity, split, and then transform back. In this case, you could try translating the polygon east or west by some amount of longitude so that no part of it crosses 180/-180, split it, then translate the parts back. That's the best Shapely can do for you."}}
{"actor":{"display_login":"sgillies"}}