Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative buffer with join-style mitre #1047

Open
theroggy opened this issue Feb 15, 2024 · 9 comments
Open

Negative buffer with join-style mitre #1047

theroggy opened this issue Feb 15, 2024 · 9 comments

Comments

@theroggy
Copy link

theroggy commented Feb 15, 2024

Quite a specific case: for a specific polygon, when I apply a negative buffer (distance -5) with join style mitre (mitre distance 2), a large part of the polygon disappears...

In the image below the input polygon is in blue, the result after applying the negative buffer is in red.

image

Code to reproduce:

from matplotlib import pyplot as plt
import shapely
import shapely.plotting

wkt = "Polygon ((192800.25198371690930799 231454.62886510850512423, 192799.81520632578758523 231453.52218602373613976, 192786.04915788403013721 231446.86360824486473575, 192801.88253643843927421 231411.54299454658757895, 192801.30145057078334503 231410.01465837462455966, 192716.32490501765278168 231371.78896312581491657, 192712.28734987965435721 231375.44304183250642382, 192714.54021742971963249 231382.17160624865209684, 192768.56934017801540904 231524.5083285111177247, 192778.11818941161618568 231550.19523288929485716, 192780.08499048536759801 231555.39736354001797736, 192780.06706917562405579 231555.429495604155818, 192813.87713734642602503 231646.39144207796198316, 192813.24304402875714004 231647.81024954235181212, 192828.236274086026242 231663.98016347750672139, 192829.7379972608468961 231662.84963450999930501, 192829.76923481578705832 231662.90687218552920967, 192835.13797317413263954 231672.21670686689321883, 192838.74942462120088749 231678.48658785136649385, 192889.72698129829950631 231765.04056633179425262, 192899.79063106325338595 231784.68724321207264438, 192904.71836394618730992 231797.77362817942048423, 192904.44099068827927113 231798.57972623527166434, 192908.84998118507792242 231809.34114382942789234, 192915.39578192730550654 231828.9553750800259877, 192918.00878075163927861 231829.40077260686666705, 192914.46051785934832878 231832.14893700383254327, 192912.85541633720276877 231837.50681109874858521, 192913.43023715176968835 231839.38160613141371869, 192910.59184958104742691 231838.42826746855280362, 192902.21572010856471024 231844.74922290549147874, 192853.78836480996687897 231890.11989867241936736, 192853.77580221343669109 231890.11864241276634857, 192848.4450350079277996 231895.12149176179082133, 192838.21739705553045496 231889.40967127529438585, 192836.12850935195456259 231887.15921214708941989, 192835.26215201613376848 231882.38847108458867297, 192831.76194672874407843 231880.03587408812018111, 192833.35543169380980544 231866.0494562903768383, 192836.30202457078848965 231862.58557266386924312, 192846.09569760735030286 231856.98149015600210987, 192846.40865821851184592 231856.05366128927562386, 192836.40483257599407807 231832.41991469555068761, 192833.53256282676011324 231824.5211728852300439, 192831.31833102478412911 231815.88566885751788504, 192832.17739028713549487 231807.92387218883959576, 192895.9172504152811598 231796.8274189644434955, 192897.38539351444342174 231793.68859221760067157, 192850.68306897408911027 231712.76509752235142514, 192832.19026185464463197 231680.57280287772300653, 192832.01862942014122382 231680.28234798859921284, 192830.64254251663805917 231678.05867132570710965, 192813.57871235493803397 231648.98433518662932329, 192810.82920577027834952 231645.86549189672223292, 192809.47861784105771221 231646.04303397191688418, 192809.43396933301119134 231645.92149081116076559, 192808.37055873320787214 231645.37608321511652321, 192801.80183777815545909 231647.20072792487917468, 192752.4831609778048005 231679.49890663541737013, 192734.39380021544639021 231695.12015135888941586, 192682.75085649755783379 231741.08141903163050301, 192682.68559480312978849 231741.46570078661898151, 192698.44373878868645988 231769.83035996064427309, 192716.76689904610975645 231795.61679986893432215, 192716.82813857996370643 231795.62128870908054523, 192727.60947156630572863 231816.16498723489348777, 192731.27823051571613178 231824.56638075172668323, 192667.52885671347030438 231854.40085114433895797, 192666.95976365191745572 231855.99384012760128826, 192667.82814148627221584 231857.8061069123505149, 192630.66964961175108328 231875.35511270837741904, 192590.32536901682033204 231769.69199562008725479, 192589.5981729646155145 231769.30065908713731915, 192495.7756118583783973 231790.15011711075203493, 192415.0532187680946663 231813.00525250378996134, 192414.27045788787654601 231808.13575167927774601, 192407.87309215069399215 231807.15003862322191708, 192389.07855140746687539 231844.59912353061372414, 192387.93428563565248623 231864.21510819019749761, 192411.18594264448620379 231995.28533796977717429, 192408.17658207967178896 232019.8239289904886391, 192407.47137072047917172 232021.58199111130670644, 192407.01404671400086954 232025.16104855330195278, 192352.96504584528156556 232156.7300528778869193, 192351.01467031831271015 232161.49096327423467301, 192350.15414678974775597 232163.58223557041492313, 192303.26592349063139409 232278.21738771288073622, 192303.93884741986403242 232279.7927760501333978, 192539.61663765838602558 232372.60537935988395475, 192559.49825207740650512 232379.86063926786300726, 192560.66032974197878502 232379.36802874502609484, 192560.74785376954241656 232379.1715125321643427, 192560.51012587067089044 232380.45790198497707024, 192560.76279075685306452 232380.91628111110185273, 192561.9358490142330993 232381.38550441362895072, 192562.92666004609782249 232382.89265358890406787, 192563.46525952045340091 232383.33036459251889028, 192561.17257465189322829 232383.85829763329820707, 192535.92900264158379287 232436.80534718171111308, 192527.55848618701566011 232455.13268773836898617, 192525.60437112807994708 232459.04091785062337294, 192525.85061900209984742 232459.3889639642147813, 192519.63208731100894511 232474.30764635978266597, 192519.63840958767104894 232474.332343098212732, 192558.30220923901651986 232505.25689741817768663, 192570.90570758713874966 232515.71038722453522496, 192461.07175790265318938 232651.28163093799958006, 192420.5935977183689829 232624.11501415411476046, 192417.98881937187979929 232624.91207459970610216, 192381.75821330811595544 232714.11673245165729895, 192379.23003117376356386 232711.90619371365755796, 192373.32804879525792785 232716.01500624587060884, 192375.23590001702541485 232721.02311570360325277, 192376.00231167644960806 232723.19220530576421879, 192378.47354798138258047 232726.4740071187261492, 192394.23271510089398362 232733.7350568154361099, 192406.3676703511737287 232739.55427430861163884, 192428.99028867826564237 232751.03111482577514835, 192441.27837567121605389 232756.4390748715668451, 192458.68545090887346305 232765.09777457479503937, 192470.77663141075754538 232770.82988977566128597, 192482.29310881957644597 232776.93741505660000257, 192483.06643510912545025 232777.3141637617663946, 192501.81225319279474206 232787.32702982850605622, 192504.89596176639315672 232789.37689390924060717, 192518.05382252918207087 232799.82693340061814524, 192548.86627046839566901 232828.01365950124454685, 192561.98033603024668992 232840.52799645508639514, 192594.93939179726294242 232870.87762636967818253, 192606.10239148835535161 232880.22818330652080476, 192625.04772713439888321 232892.52782647011918016, 192643.63952211424475536 232902.66973217457416467, 192655.76996795603190549 232908.02321975270751864, 192668.39747057147906162 232912.45464227901538834, 192675.28866301331436262 232914.44427979603642598, 192684.23723168880678713 232916.60676474639330991, 192707.28671687084715813 232920.6749988810333889, 192770.76497748770634644 232842.53522798043559305, 192813.31242550519527867 232789.1887326360156294, 192836.56705439355573617 232763.47255525083164684, 192850.7138776911306195 232745.41449224983807653, 192863.24628754629520699 232730.08600688909064047, 192899.5329030393040739 232684.81279991441988386, 192903.63645668761455454 232679.61563416908029467, 192907.76439408725127578 232674.37203801280702464, 192911.63812869536923245 232669.06902891132631339, 192911.76885447942186147 232663.99686849268618971, 192910.56288243364542723 232662.17068225200637244, 192909.09648780227871612 232659.91269405858474784, 192906.72686511883512139 232657.74261854845099151, 192905.5437751499703154 232656.66093402204569429, 192844.50352501097950153 232608.28318247699644417, 192830.5920382282929495 232596.32768666232004762, 192826.24092836008640006 232592.7713931166799739, 192785.86718021632987075 232560.91476437554229051, 192785.16370083412039094 232560.35990728120668791, 192725.61632455958169885 232513.03404491452965885, 192710.28221539524383843 232501.03300255941576324, 192707.55067027756012976 232498.89384072029497474, 192706.69442835947847925 232498.77967513116891496, 192698.59283302642870694 232491.53488776518497616, 192698.39844891024404205 232491.3648016634688247, 192680.03065662924200296 232476.84750989897293039, 192631.37415711453650147 232438.37984671094454825, 192633.61069369336473756 232437.98288048247923143, 192633.62898876107647084 232437.95215415078564547, 192633.63484389637596905 232437.96630640444345772, 192633.51028010400477797 232438.37277772690868005, 192657.53590486120083369 232457.81729268192430027, 192672.38375702747725882 232470.46101024863310158, 192737.07912954624043778 232521.2723982373427134, 192737.95294938643928617 232522.07560637325514108, 192738.50536789436591789 232522.56883718390599824, 192740.96218751720152795 232524.24037199580925517, 192743.58999999999650754 232526.03798784568789415, 192743.58999999999650754 232526.58831015991745517, 192745.80613698324305005 232528.45187989578698762, 192746.50882385979639366 232529.04646109903114848, 192789.98717906084493734 232563.60489585704635829, 192800.37103793551796116 232571.95995458585093729, 192800.81439930238411762 232572.31464367933222093, 192826.49502517431392334 232592.05445165128912777, 192832.76172504608985037 232598.01180805807234719, 192841.92215053900144994 232605.16041212165146135, 192845.80953415669500828 232608.19963931367965415, 192849.52673673687968403 232606.86063317104708403, 192855.49209751808666624 232579.64054153926554136, 192919.50241922790883109 232581.84642961548524909, 192918.88445933244656771 232588.02602856984594837, 192917.52506321200053208 232611.41771144230733626, 192916.30898886188515462 232646.25466488435631618, 192917.50606367166619748 232651.16367754968814552, 192917.38954608884523623 232656.19335320743266493, 192917.99913125287275761 232659.54607160922023468, 192922.39653397185611539 232663.95994400134077296, 192925.12685555423377082 232665.2275933074997738, 192960.08149505700566806 232664.04156093398341909, 192922.19341563477064483 232667.21885490595013835, 192909.53603150777053088 232675.14850377454422414, 192868.37171355160535313 232724.70790923503227532, 192847.13947025814559311 232752.03375615930417553, 192830.2759766562958248 232774.70624178560683504, 192827.72400038444902748 232780.88987659817212261, 192823.86363902481389232 232806.93704885718761943, 192820.24017160257790238 232837.29365370573941618, 192819.12932134311995469 232853.61698112945305184, 192820.09673285990720615 232869.01323250317364, 192821.28074574892525561 232880.06742180325090885, 192824.1307107700558845 232898.55826628542854451, 192829.96705342881614342 232902.89904613792896271, 192870.05982268255320378 232909.17086822880082764, 192884.65518619923386723 232931.03106220325571485, 192888.17992303089704365 232934.60867008741479367, 192883.52317678884719498 232941.84378319612005726, 192883.83850210611126386 232943.36052349352394231, 192916.7698694329301361 232965.36021374762640335, 192918.21366124899941497 232965.0968009339121636, 192925.63976374012418091 232954.71494442282710224, 192947.68821440875763074 232970.23499845754122362, 192942.1701671862101648 232986.24941871801274829, 192924.76053885917644948 233021.07964552222983912, 192924.96754859320935793 233021.89091663362341933, 192948.8933581218298059 233038.52788951082038693, 192950.67605876186280511 233038.1777009878132958, 192971.55617653668741696 233005.97581951369647868, 192981.81405613015522249 232983.90794663460110314, 192984.59929442885913886 232980.04247964563546702, 192995.5841574429650791 232981.26558414089959115, 192999.9692972571356222 232982.47234742311411537, 193023.59184762451332062 232993.35375672130612656, 193036.73519013344775885 232998.62738291773712263, 193046.10733076045289636 233001.84925563159049489, 193042.52411234023747966 233008.89743443831684999, 193031.50505202397471294 233038.46160773732117377, 193032.01802369666984305 233039.67745134286815301, 193056.35700390723650344 233050.41648024873575196, 193058.42658363949158229 233049.4689355660811998, 193060.46776817011414096 233042.78869528393261135, 193067.39254103956045583 233046.55884940174291842, 193069.16645849181804806 233045.99623190480633639, 193091.66301979203126393 233000.35797202377580106, 193094.40377602443913929 233001.71837972523644567, 193082.89317181007936597 233024.72046754890470766, 193083.38796979136532173 233026.23089765457552858, 193099.60730838170275092 233034.54490507373702712, 193103.42132690502330661 233036.27148405590560287, 193101.73627185504301451 233060.55023581147543155, 193172.30919041112065315 233094.16163518626126461, 193173.79342635755892843 233093.64592746019479819, 193178.11859773710602894 233084.86102381374803372, 193181.13606766925659031 233058.56592869080486707, 193232.38928018801379949 233065.46942262188531458, 193228.53661313591874205 233094.60521720329415984, 193229.7002736677241046 233096.06065371001022868, 193252.65032217907719314 233098.14153852904564701, 193254.22000000000116415 233096.70774464774876833, 193254.22000000000116415 233095.65110919356811792, 193255.06692090295837261 233097.15471953514497727, 193313.9969011256180238 233088.89882858606870286, 193314.99244044025545008 233087.57536166170029901, 193311.42660263399011455 233062.59072476570145227, 193308.3413953969720751 233047.9385359403968323, 193307.55605990326148458 233044.84886077445116825, 193305.81739445024868473 233038.00152399035869166, 193304.49850458325818181 233035.20858074256102555, 193303.57967469719005749 233032.8314245235233102, 193300.62700934868189506 233021.33676744770491496, 193298.03385881552821957 233013.2115624439320527, 193296.10626162405242212 233007.15628330843173899, 193290.42687522363848984 232990.6900764477904886, 193286.78337503285729326 232980.12091473731561564, 193282.43908230363740586 232968.17160147987306118, 193278.24404722635517828 232956.66438154969364405, 193276.7901065269834362 232955.98147818757570349, 193250.23885057296138257 232965.46324466788792051, 193234.43343111017020419 232970.72888226070790552, 193234.47374301648233086 232961.73622623886330985, 193227.61310126184253022 232941.75995884675648995, 193178.55870231194421649 232807.48062344960635528, 193214.10195687462692149 232803.63445289063383825, 193215.69075747058377601 232800.9732645487820264, 193167.68800566316349432 232683.03636139104492031, 193160.40473524606204592 232669.22326232411433011, 193155.41950439114589244 232657.90912511045462452, 193152.60235866837319918 232650.22926288528833538, 193151.76561424872488715 232649.7765742008050438, 193144.51543691215920262 232651.45414182922104374, 193141.02665752900065854 232651.97556266095489264, 193121.52519520701025613 232654.92461271680076607, 193120.86722129772533663 232654.98553622688632458, 193120.7270901253214106 232655.01356246136128902, 193120.39515868620947003 232655.04977316380245611, 193115.85938445702777244 232655.54939408323843963, 193114.35118856074404903 232655.65627410737215541, 193111.14082265429897234 232656.32387313377694227, 193092.35532254326972179 232657.19830279378220439, 193075.37623333823285066 232658.41294083429966122, 193074.64658911045989953 232659.16945603408385068, 193072.97890219095279463 232706.44946311510284431, 193072.89611109610996209 232707.2664804985106457, 193062.0684238221438136 232712.54804872375098057, 193057.07905715482775122 232727.18641666768235154, 193041.0641354170802515 232723.78144231621990912, 193040.13154645578470081 232724.32151934591820464, 193039.38962966474355198 232726.62605734285898507, 193038.45235872775083408 232726.31297734499094076, 193038.37509640704956837 232726.16950883864774369, 193026.51480092728161253 232722.0030688317201566, 193024.87509790837066248 232722.82657911806018092, 193007.96391928123193793 232777.0904308422759641, 192994.52893738783313893 232820.72051213454687968, 192994.01243347881245427 232820.43050297914305702, 192988.70351081146509387 232816.11105693795252591, 193018.93505082718911581 232730.14105943901813589, 193016.69475780759239569 232727.17885330782155506, 192992.0162132557888981 232728.72033597051631659, 192990.83132959724753164 232730.11021527962293476, 192992.0986687452532351 232743.2000181938346941, 192972.48003181259264238 232744.18919316522078589, 192969.70126470166724175 232703.94589823251590133, 192969.98845492320833728 232664.78861609779414721, 192968.86055427009705454 232663.74368206626968458, 192978.69480213322094642 232663.41000000000349246, 192982.59542335409787484 232663.41000000000349246, 192984.02021017018705606 232661.85524118936154991, 192978.89846590763772838 232603.26018491864670068, 192977.80881844490068033 232602.31164009586791508, 192944.7283821927558165 232604.00188136423821561, 192943.84401876354240812 232587.34637011407176033, 192975.21292221933254041 232594.49663487236830406, 192977.08001365611562505 232593.15536425667232834, 192979.27223247379879467 232571.47675594864995219, 193027.04158121068030596 232571.23052219228702597, 193027.56706892236252315 232570.78261572433984838, 193034.59488242279621772 232528.37339632512885146, 193039.55060899013187736 232529.32081463947542943, 193040.57430691848276183 232529.03645410382887349, 193116.29498779107234441 232624.61829717247746885, 193118.41508438345044851 232653.73429037479218096, 193119.9736365245480556 232654.99234401845023967, 193130.9710268282215111 232653.4438609009666834, 193147.37759370837011375 232649.80667940760031343, 193147.78140201410860755 232649.28012832350214012, 193145.82018492801580578 232604.92114287335425615, 193174.32145537214819342 232600.08731196864391677, 193178.02354279733845033 232583.42791855524410494, 193178.66998844867339358 232581.08455306917312555, 193205.66545000256155618 232588.31995336432009935, 193207.4843624237109907 232587.14812161223380826, 193227.43897223190288059 232466.77976581428083591, 193228.03902418981306255 232462.77941942814504728, 193285.67567716719349846 232483.64152897612075321, 193288.03742705227341503 232482.21187655080575496, 193301.43481479707406834 232383.45696859856252559, 193303.40559703623875976 232364.66486320723197423, 193304.07789939208305441 232360.75228392300778069, 193303.826771889871452 232354.76109922758769244, 193303.02604640467325225 232353.95418070236337371, 193295.8848470855737105 232353.59971439235960133, 193297.00304628367302939 232318.71783675136975944, 193292.43741166903055273 232316.36792189747211523, 193289.29386471671750769 232318.76844866111059673, 193284.0374333455984015 232318.2428055240015965, 193284.02615155457169749 232318.0564303366409149, 193285.38858195923967287 232314.49315081693930551, 193285.01768385095056146 232313.96547261576051824, 193298.03714441612828523 232313.92938263498945162, 193299.10251204617088661 232312.88752985876635648, 193299.8251379357825499 232284.09156988028553315, 193299.76316672933171503 232284.02814331016270444, 193299.84486689293407835 232263.003967866912717, 193298.71377381822094321 232261.85741074400721118, 193204.38419075470301323 232260.94306906647398137, 193203.23717111314181238 232262.05951226965407841, 193202.83107997736078687 232285.49947038546088152, 193202.05699044358334504 232285.45347063601366244, 193202.88062604030710645 232240.45825798629084602, 193240.8727827837865334 232239.89901921182172373, 193247.89726436155615374 232237.75264984084060416, 193248.62181087926728651 232201.16305069453665055, 193209.10786219159490429 232187.95877871161792427, 193166.55942314161802642 232174.86540891914046369, 193158.60442192893242463 232172.60269811502075754, 193151.02056456077843904 232170.66049074023612775, 193136.45158847805578262 232167.81379618114442565, 193130.86348893548711203 232166.95018079731380567, 193129.32294390277820639 232166.70581848177243955, 193122.48974364940659143 232165.90497157233767211, 193114.68561248763580807 232165.50396878534229472, 193060.94348810325027443 232163.84142822481226176, 193039.24375183586380444 232163.44050930996309035, 193002.86295031558256596 232163.03928734667715617, 192986.91099494200898334 232163.45166450325632468, 192976.36677765645436011 232163.72336881386581808, 192971.84515644310158677 232164.67339029221329838, 192966.53030786116141826 232166.53185041729011573, 192964.70375033878372051 232170.30280788286472671, 192963.00662751338677481 232173.77678413610556163, 192961.62038191262399778 232178.92740356651484035, 192961.47888072457863018 232180.24336461577331647, 192960.58431337308138609 232188.49778154076193459, 192960.09703998093027622 232197.67476375962723978, 192959.72297582207829691 232204.71307622196036391, 192958.2333865026012063 232219.89888948568841442, 192956.10328475237474777 232258.74548443773528561, 192956.42455097966012545 232265.29931547425803728, 192956.92526603417354636 232269.49280405562603846, 192957.66525255556916818 232275.67325704958057031, 192958.78915563281043433 232280.71506524653523229, 192960.19705219523166306 232287.06536792326369323, 192964.88903221537475474 232313.07290497416397557, 192965.81273841977235861 232334.73624627265962772, 192965.71238275579526089 232336.20812934459536336, 192965.3629438690841198 232341.00043407635530457, 192965.01702603025478311 232345.85316718678222969, 192964.17290336411679164 232354.64197376943775453, 192963.30702487390954047 232363.67895710791344754, 192960.39213563242810778 232389.30402793971006759, 192958.46709104234469123 232406.17531616782071069, 192957.80212631169706583 232409.43457991801551543, 192955.46334338723681867 232420.75868698375415988, 192951.20937100780429319 232441.42225340867298655, 192949.9528527248185128 232446.22429614909924567, 192949.27270488659269176 232448.82486127800075337, 192946.45760364219313487 232459.59568316582590342, 192947.38319001236231998 232461.12782854048418812, 192974.4794509369530715 232467.42302023543743417, 192974.99239290374680422 232508.41338266804814339, 192971.60574213293148205 232522.14536031984607689, 192934.99276597207062878 232512.69403605270781554, 192933.70311135463998653 232513.48428740390227176, 192936.31661744436132722 232499.33758449714514427, 192937.91160436096834019 232492.43582012335537001, 192940.87163530351244844 232479.62568622158141807, 192942.32815772938192822 232473.30739536599139683, 192949.17088745060027577 232442.12053085552179255, 192954.42665439151460305 232420.6561391502909828, 192955.01010627113282681 232417.61385434935800731, 192957.14103893758147024 232406.5540136790368706, 192956.88116057755541988 232406.07595333867357112, 192890.72648686816683039 232379.29882406163960695, 192896.09584090168937109 232342.64818871690658852, 192961.01081888287444599 232357.20316040841862559, 192962.99740286590531468 232355.71066799567779526, 192963.79079507014830597 232342.84328897352679633, 192964.00378732467652299 232339.28631832334212959, 192963.79848313235561363 232331.17680272707366385, 192963.6250263744732365 232323.94263558939564973, 192962.75466812046943232 232313.47761372567038052, 192961.28761192690581083 232304.95227318827528507, 192960.57856300642015412 232300.82966017912258394, 192955.63367136294255033 232275.36048936494626105, 192955.39724562276387587 232272.92348558129742742, 192954.84065823163837194 232267.03133630281081423, 192954.85976039225351997 232260.19276279755285941, 192955.22472190219559707 232249.5595598871295806, 192959.52255138062173501 232179.81249967953772284, 192959.48948534292867407 232177.81751540541881695, 192959.44570929073961452 232174.29354320245329291, 192959.01068365180981345 232171.16135860199574381, 192958.0560040564450901 232169.58502717720693909, 192957.17869773667189293 232168.11293691181344911, 192955.14297646802151576 232166.00515471328981221, 192953.75443733064457774 232165.21953388553811237, 192952.25818916049320251 232164.37091552038327791, 192950.71977694737142883 232164.1549980167474132, 192949.23176426428835839 232163.96155636798357591, 192880.70870748537709005 232167.86254233488580212, 192880.10884313718997873 232168.44431023328797892, 192880.01493107815622352 232169.51490770597592928, 192878.68757645590812899 232169.56406898828572594, 192877.81846284423954785 232170.43222486824379303, 192876.97977398376679048 232192.42129717508214526, 192820.83012814467656426 232194.69750963561818935, 192820.84437027288367972 232192.46386919749784283, 192819.69628952204948291 232191.29955657248501666, 192818.24275018979096785 232191.28841834006016143, 192818.26514615034102462 232187.88423233397770673, 192817.11232699936954305 232186.71596291026799008, 192803.49452859026496299 232186.6242605640727561, 192803.01990688525256701 232187.09284959358046763, 192798.39934441991499625 232187.11071259281015955, 192798.364125275722472 232178.57007012481335551, 192797.19429645896889269 232177.41086601809365675, 192781.5159387304156553 232177.48925780673744157, 192780.35906365228584036 232178.65831264617736451, 192780.47108228158322163 232199.12571647990262136, 192781.63533027618541382 232200.27813515643356368, 192782.58809122123057023 232200.27361970170750283, 192782.61160529847256839 232204.4669634748424869, 192783.78042576066218317 232205.62244606093736365, 192802.21592171269003302 232205.51424065546598285, 192802.15543174702906981 232215.4997380624699872, 192795.90899845483363606 232216.19378620604402386, 192793.96885501744691283 232209.90244729263940826, 192769.84211288849473931 232210.14704119096859358, 192764.13632594011141919 232176.69217619436676614, 192762.9481703441706486 232175.82222939442726783, 192743.12459100430714898 232178.57275102782296017, 192738.60558349057100713 232179.27105240966193378, 192725.08297708255122416 232181.08603350570774637, 192704.79724185875966214 232183.9079600393306464, 192703.5935102631628979 232184.11216450642677955, 192703.31845617515500635 232184.16000000000349246, 192701.92701853651669808 232184.16000000000349246, 192674.26270138690597378 232187.63699126761639491, 192673.47402386739850044 232187.73088144851499237, 192647.62558684634859674 232190.43814939990988933, 192634.37294016717351042 232191.3620595506799873, 192614.93361200660001487 232192.71201289517921396, 192607.58381055929930881 232193.22639934648759663, 192595.0959259484661743 232193.68414540326921269, 192593.95365677247173153 232194.92317909034318291, 192596.83089440889307298 232259.41166531440103427, 192555.54409489477984607 232249.77870346678537317, 192555.50271384359803051 232249.79707969250739552, 192555.01841929394868203 232250.67158609264879487, 192553.29625697698793374 232250.19460442880517803, 192547.77305369134410284 232254.35964297215105034, 192543.1742311840353068 232255.64731327418121509, 192521.50923965399852023 232254.93308278417680413, 192515.33067425861372612 232253.94451232091523707, 192502.55837090403656475 232253.15414701431291178, 192502.1189100356423296 232253.19927022847696207, 192501.00845076868426986 232248.07649115734966472, 192496.46635862797847949 232201.22805507748853415, 192495.21063535250141285 232200.19160017790272832, 192486.7985922135412693 232200.98541269949055277, 192487.97510983096435666 232194.4194348412565887, 192478.07636297849239781 232142.76083178666885942, 192620.52096530186827295 232133.50270932380226441, 192621.39999999999417923 232132.56468747064354829, 192621.39999999999417923 232128.60500430263346061, 192621.347657840087777 232127.35926089686108753, 192621.18881344399414957 232120.24104639657889493, 192621.16576154885115102 232119.15760732427588664, 192620.95454244941356592 232116.51249429443851113, 192623.57119593847892247 232118.22465146743343212, 192653.69262913113925606 232106.44249727157875896, 192664.61798263882519677 232101.83417280623689294, 192665.03632728871889412 232102.0003539884055499, 192667.81931049172999337 232100.91394878082792275, 192694.07551011047326028 232161.84814789606025442, 192697.86540211629471742 232162.48109204572392628, 192720.09524968420737423 232138.02825972103164531, 192743.72448355887900107 232125.80624219964374788, 192767.62122024514246732 232175.50951562379486859, 192804.10562178335385397 232172.79126561174052767, 192805.15629141451790929 232171.58021015056874603, 192805.14215409272583202 232171.37021920018014498, 192805.51945361576508731 232172.52742444458999671, 192805.73956116841873154 232172.67499747066176496, 192831.30602112517226487 232170.76999999998952262, 192831.48441894855932333 232170.76999999998952262, 192850.39254568834439851 232168.22934016122599132, 192851.17779032303951681 232167.27553333475952968, 192850.2712214470084291 232152.1038365563726984, 192849.68557157603208907 232142.16405680179013871, 192848.46077823010273278 232141.07492864417145029, 192838.38444691241602413 232141.6627836347615812, 192838.54263750888640061 232140.26185843726852909, 192842.2289456409343984 232139.00735566980438307, 192844.33325317039270885 232125.38331333166570403, 192844.23566143764765002 232123.76999999998952262, 192848.17518533076508902 232123.76999999998952262, 192849.31557528147823177 232122.63682002935092896, 192849.46326315758051351 232099.35136489677825011, 192852.54845830571139231 232099.2247545949940104, 192854.02770395207335241 232124.59776961334864609, 192854.10505706514231861 232126.05780962217249908, 192854.11623077891999856 232126.35000223727547564, 192850.13837954495102167 232126.57888653449481353, 192849.03607085373369046 232127.81986641173716635, 192850.90228395714075305 232158.50574187000165693, 192852.13548375316895545 232159.59666317887604237, 192861.64528011120273732 232159.01067220608820207, 192944.85342568086343817 232153.95822496947948821, 192945.93484661862021312 232152.73995585617376491, 192944.29632947835489176 232124.63215814903378487, 192944.4054129104479216 232124.50925888103665784, 192942.66445342494989745 232094.72507430249243043, 192952.66952096743625589 232094.2190504782483913, 192953.83531555350054987 232092.9004324123961851, 192951.41336887708166614 232059.47756827785633504, 192957.01800554379587993 232119.2259449538832996, 192959.70953866204945371 232154.08970987622160465, 192966.28328546439297497 232161.14030877820914611, 192996.64061518860398792 232160.57973308724467643, 193024.19980492486502044 232160.42037384051945992, 193068.97072327695786953 232161.57832847346435301, 193110.58139176876284182 232162.65343665637192316, 193126.69898776811896823 232164.29674783087102696, 193128.82867475456441753 232161.97718325880123302, 193115.99807054965640418 232094.13154782386845909, 193143.58587215954321437 232089.70034652898903005, 193143.95725800294894725 232089.27839843335095793, 193144.23676469695055857 232080.53746182160102762, 193147.1940657556115184 232077.41213229368440807, 193143.15278305840911344 232045.0695120531891007, 193141.68655990206752904 232043.9699952008377295, 193112.36665991003974341 232048.69012011145241559, 193108.24911632013390772 232049.31647961016278714, 193108.66258440483943559 232048.74121847675996833, 193107.4655600150290411 232041.09854546343558468, 193127.69205334296566434 232037.95008187938947231, 193128.66017246062983759 232036.62534884223714471, 193128.60953454655827954 232036.29950487340101972, 193131.54619875701609999 232035.84715806349413469, 193132.52110766328405589 232034.51499942486407235, 193130.09006043174304068 232018.89795200937078334, 193128.76557914476143196 232017.92997482218197547, 193104.42898396390955895 232021.71083871636074036, 193100.53521066266694106 231996.8501622065086849, 193099.17842224886408076 231995.86719839859870262, 193095.5712336034339387 231996.45488643628777936, 193070.16488071728963405 231999.33961998706217855, 193069.37472445354796946 232000.67803735216148198, 193048.64737573929596692 232003.97777580964611843, 193036.91837778440094553 231939.72286278268438764, 193070.75180939098936506 231883.6316168126068078, 193080.67007301197736524 231868.01035160955507308, 193090.6869602566875983 231853.4858651046815794, 193118.59116590992198326 231808.3596161465102341, 193106.75384615297662094 231792.13453224344993941, 193066.66191080384305678 231739.86773486490710638, 193068.32240230505703948 231739.19280186662217602, 193067.33685003680875525 231732.37174274696735665, 193067.83387244769255631 231730.32717328408034518, 193069.20106796600157395 231727.81760995491640642, 193070.49508867529220879 231726.92394924405380152, 193072.6244615645846352 231726.98373725175042637, 193075.60429774399381131 231728.14256243265117519, 193078.13655649707652628 231730.1683694350940641, 193082.74042577974614687 231737.17844217558740638, 193085.21901655636611395 231737.48626185490866192, 193101.83995757324737497 231722.23125999068724923, 193129.18640508013777435 231698.23062580023542978, 193129.30766843393212184 231696.819912805367494, 193112.07112062314990908 231675.4600668323400896, 193098.12531033632694744 231658.17765150553896092, 193088.45945594139629975 231645.9755088705860544, 193085.55859834386501461 231642.31280988379148766, 193068.60520939948037267 231618.83436486168648116, 193063.90481945656938478 231619.51445882781990804, 193054.12344792587100528 231647.34199057437945157, 193034.53512318641878664 231700.8861738521954976, 193035.18990697443950921 231702.3828225105535239, 193033.46828974070376717 231702.59318316186545417, 193028.14063902306952514 231714.81218467798316851, 193022.15649063655291684 231722.61759561690269038, 193018.12345256883418187 231727.31320422430871986, 193002.8099526442529168 231743.53641701571177691, 192998.7416011490568053 231749.3008095036202576, 192997.07974239709437825 231751.92973860274651088, 192996.12519987145788036 231753.07373231669771485, 192995.73462045771884732 231753.46431173043674789, 192993.53721620747819543 231757.55029584976728074, 192991.34472484825528227 231761.62051495726336725, 192988.25655414105858654 231770.12832299823639914, 192988.60877396116848104 231768.8172825567307882, 192989.46208607230801135 231765.63846092295716517, 192991.32257512761862017 231760.54273720493074507, 192994.80363076238427311 231753.51293874246766791, 192995.23144415469141677 231752.64328528929036111, 193000.91162163455737755 231744.76192244773847051, 193020.02964413264999166 231723.69918717601103708, 193029.20781062584137544 231711.75907243258552626, 193027.88610793394036591 231708.10705891749239527, 192975.71460917650256306 231696.38829667080426589, 192989.79115378830465488 231649.58621282703825273, 192988.69400843983748928 231647.75343709060689434, 192960.8455998420540709 231642.11350713315187022, 192961.33343096502358094 231641.6271589619864244, 192961.37655516795348376 231616.39950024872086942, 192960.21572301260312088 231615.23512888007098809, 192907.58772936201421544 231615.16488016775110736, 192907.15496672003064305 231615.59657329745823517, 192907.05168323978432454 231597.20416893184301443, 192878.58114604197908193 231584.72668536179116927, 192875.13929101807298139 231583.19286646010004915, 192886.02346956825931557 231557.7559128651919309, 192885.4563600892724935 231556.30729379467084073, 192876.79135501885320991 231552.43569578451570123, 192868.7313972296542488 231548.82742639310890809, 192879.12608726572943851 231525.26250081387115642, 192879.20051737054018304 231525.23404454084811732, 192891.96028311573900282 231496.65375927346758544, 192891.75144740846008062 231496.10687602742109448, 192903.48904158410732634 231470.96730924272560515, 192902.88072147252387367 231469.33873955075978301, 192872.87673072121106088 231455.97514931642217562, 192869.53345182188786566 231453.64939008202054538, 192866.93659168301383033 231454.39040199792361818, 192856.17522353451931849 231479.34995122565305792, 192815.76026118570007384 231461.23655533252167515, 192814.21153522489476018 231461.82932128780521452, 192804.54291226371424273 231483.57537193252937868, 192804.07347950077382848 231482.41414607397746295, 192812.72662553589907475 231463.24903004060615785, 192812.14741348096868023 231461.71515163526055403, 192799.69028571844683029 231456.08367510890820995, 192800.25198371690930799 231454.62886510850512423),(192969.32316903461469337 231821.29526354043628089, 192972.19081389479106292 231818.61794909136369824, 192974.94876832840964198 231815.48625316907418892, 192975.97202010339242406 231813.35447863783338107, 192976.47990423554438166 231812.28524888594984077, 192977.64276014428469352 231808.87275584536837414, 192980.63752958105760626 231800.07500772897037677, 192977.63928195252083242 231810.70719757382175885, 192974.28451377779128961 231817.85241810182924382, 192970.79116522028925829 231821.69108617192250676, 192968.82396802183939144 231823.11254479273338802, 192967.3785931839956902 231823.5246034087613225, 192965.75877080895588733 231823.994117140682647, 192964.3369604779582005 231824.1236063075484708, 192967.57834796726820059 231822.28825113974744454, 192969.32316903461469337 231821.29526354043628089),(192987.60831045522354543 231772.54123005107976496, 192985.83928749928600155 231779.61732187480083667, 192981.51694821217097342 231796.95647083761286922, 192980.92273658703197725 231799.06362527885357849, 192986.64043901886907406 231776.14386261967592873, 192987.60831045522354543 231772.54123005107976496),(192946.42819270479958504 232006.33296650453121401, 192950.56287093210266903 232050.41081255392055027, 192948.08286163202137686 232025.79789006646024063, 192946.42819270479958504 232006.33296650453121401),(192940.69243546205689199 231949.08939540470601059, 192941.83208112244028598 231957.33599803049582988, 192943.43148376327008009 231974.38647197265527211, 192942.40166627481812611 231964.18760091735748574, 192940.69243546205689199 231949.08939540470601059),(192936.83064076048322022 231921.1450198556703981, 192936.99839432965382002 231922.35890332143753767, 192936.06856922371662222 231917.50113410947960801, 192936.83064076048322022 231921.1450198556703981),(192930.35298550617881119 231897.35473881437792443, 192919.89143442575004883 231860.45499151948024519, 192930.40000526153016835 231894.7290050977608189, 192934.8319388572126627 231911.58811997840530239, 192935.51210135855944827 231914.84035329794278368, 192932.99561283414368518 231905.84317811019718647, 192930.35298550617881119 231897.35473881437792443),(192620.55347256120876409 232111.48986523319035769, 192620.02343812788603827 232104.85220325272530317, 192620.33708191011101007 232105.95988192668301053, 192620.55347256120876409 232111.48986523319035769),(192786.65125043207081035 232107.45520337400375865, 192815.82168043707497418 232096.44334490300389007, 192833.51532070097164251 232090.56618336334940977, 192817.13693050484289415 232100.60680526299984194, 192802.21141104414709844 232108.10364152176771313, 192788.61340435961028561 232113.36253913457039744, 192786.65125043207081035 232107.45520337400375865),(192835.87727894535055384 232089.7816297076351475, 192835.89633800464798696 232089.88683956532622688, 192835.33502455466077663 232089.96174621290992945, 192835.87727894535055384 232089.7816297076351475),(193259.4693184154748451 232310.3360827730211895, 193253.54467132376157679 232289.16852180360001512, 193248.95220075384713709 232289.07267893952666782, 193248.97931529246852733 232286.35851362437824719, 193273.75543039618059993 232286.8468091526592616, 193273.82733089310931973 232302.80871948102139868, 193274.80614746717037633 232303.78313690173672512, 193274.750983150646789 232311.68739539626403712, 193262.26258593812235631 232311.93378429280710407, 193260.25105485861422494 232311.25519549488672055, 193259.4693184154748451 232310.3360827730211895))"

poly = shapely.from_wkt(wkt)
poly_bufm = shapely.buffer(
    poly, distance=-5, join_style="mitre", mitre_limit=2.0,
)

print(f"poly.is_valid: {poly.is_valid}")
print(f"poly_bufm.is_valid: {poly_bufm.is_valid}")

shapely.plotting.plot_polygon(poly)
shapely.plotting.plot_polygon(poly_bufm, color="red")
plt.show()
@pramsey
Copy link
Member

pramsey commented Feb 15, 2024

But with a non-mitre end-cap? (I kind of wonder what a mitre even means in the case of polygon buffer/unbuffer)

@theroggy
Copy link
Author

theroggy commented Feb 15, 2024

As far as I know an end-cap is irrelevant for a polygon as it doesn't have any endings?

Regarding join-cap mitre (distance) for polygon buffer: look at the bottom of the following page for some examples/illustrations: geofileops.buffer

@pramsey
Copy link
Member

pramsey commented Feb 15, 2024

You specified mitre in your description so I wondered if you were seeing it having an effect. I agree, for polygons it should be a no-op.

@theroggy
Copy link
Author

theroggy commented Feb 15, 2024

You specified mitre in your description so I wondered if you were seeing it having an effect. I agree, for polygons it should be a no-op.

The mitre join-style is definitely important, and does have an impact on the output as shown in the examples for geofileops.buffer. Only the end-style is a no-op for polygons. If join-style mitre isn't specified, the problem doesn't occur.

@theroggy theroggy changed the title Negative buffer with join style mitre Negative buffer with join-style mitre Feb 15, 2024
@mwtoews
Copy link
Contributor

mwtoews commented Feb 15, 2024

Interestingly, this issue only happens with mitre_limit exactly 2.0. A brute-force check with other limits does not yield the bad result. Not even 1.999999999999 or 2.000000000001 trigger this error, so there could be logic quirks based on mitre_limit==2.0

@pramsey
Copy link
Member

pramsey commented Feb 15, 2024

Or an interaction with some element of the input that is itself has a size of exactly 2?

@mwtoews
Copy link
Contributor

mwtoews commented Feb 15, 2024

Actually, it more complicated. Other combinations trigger the same error, e.g., here's a few others:

for distance in np.round(np.linspace(-0.1, -10.1, 101), 1):
    for mitre_limit in np.round(np.linspace(0.1, 5.1, 51), 1):
        g = shapely.buffer(poly, join_style="mitre", distance=distance, mitre_limit=mitre_limit)
        if g.area < 700000.0:
            print(f"> {distance=}, {mitre_limit=}, {g.area:.1f}")

distance=-2.5, mitre_limit=2.9, 122669.6
distance=-3.4, mitre_limit=1.8, 120603.6
distance=-3.9, mitre_limit=3.2, 119437.9
distance=-5.0, mitre_limit=2.0, 116924.9
distance=-5.1, mitre_limit=1.7, 116704.2
distance=-5.4, mitre_limit=2.0, 116008.0
distance=-9.6, mitre_limit=0.9, 107042.7

@theroggy
Copy link
Author

theroggy commented Feb 15, 2024

I did some random tests with some other mitre limits than 2, and also noticed that it is quite specific.

The combinations with other distances leading to the issue is an interesting find indeed...

@theroggy
Copy link
Author

theroggy commented Feb 15, 2024

Probably not super relevant, but something I forgot to mention... the input polygon is the result of a +5 meter buffer on a polygon, with a mitre limit of 1.5...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants