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

Protect line endpoints? #1

Open
MattReimer opened this issue Jan 12, 2017 · 6 comments
Open

Protect line endpoints? #1

MattReimer opened this issue Jan 12, 2017 · 6 comments

Comments

@MattReimer
Copy link

Hey. Love your module but I'm having a problem with my endpoints moving around:

figure_1

The yellow lines represent separate LineString objects from the red line. You can see that when I run your smoothing algorithm the endpoint moves.

Is this something I'm doing wrong?

@cayetanobv
Copy link
Member

Hi @MattReimer ,

Thanks for use GeoSmoothing. Output endpoints should be the same that input endpoints. I tested a lot (... but certainly not enough) and I did not found a use case when this asumption fails. Could you attach to this issue or send me by email the Linestring of your example (WTK representation or Shapefile) to see what is failing?

Thanks again!

@MattReimer
Copy link
Author

first, a little change I had to make:

    def smoothObj(self, geoObj):
        return self.__smoothGeom(geoObj)

This was so I can use it on a per-object basis and not just through files. I've forked the project so I'll go through the pull-request mechanism if we can figure this out. I'm happy to help you improve this or test it since it's so useful!

The problem I'm seeing seems to be related to larger values of spl_smpar

import shapely
import matplotlib.pyplot as plt

from geosmoothing.geosmoothing import GeoSmoothing


linewkt = 'LINESTRING (470094.2973832478164695 5118813.8709880253300071, 470096.9752980942721479 5118814.6954176332801580, 470097.4422798639861867 5118814.4778696941211820, 470097.5662393854581751 5118814.5265956781804562, 470097.6180909028626047 5118814.5491494033485651, 470098.1905098260613158 5118814.9649004070088267, 470098.8066079259151593 5118815.4633529139682651, 470098.8194906431017444 5118815.4745216080918908, 470098.8805639947531745 5118815.4878381090238690, 470099.4784352184506133 5118815.5875204382464290, 470099.6834050531033427 5118815.6329526202753186, 470100.0602530135656707 5118815.7031131004914641, 470100.1544296219944954 5118815.7534984750673175, 470100.2864653847645968 5118815.8337268223986030, 470101.0584877016372047 5118816.2660199832171202, 470101.0595161573146470 5118816.2666755374521017, 470101.2992030436289497 5118816.3827558932825923, 470101.3473046002327465 5118816.4214515881612897, 470101.5960170511389151 5118816.5912749907001853, 470101.6998468230594881 5118816.6476590028032660, 470102.1407351396046579 5118816.9409958068281412, 470102.4070003498927690 5118817.0554322497919202, 470102.8122199093340896 5118817.2690943330526352, 470102.8903725738055073 5118817.3055134462192655, 470103.2187448543263599 5118817.4828798640519381, 470103.2520836098119617 5118817.5021777581423521, 470103.6205597129883245 5118817.6913878861814737, 470103.6821894736494869 5118817.7273753369227052, 470104.1124226272222586 5118817.9500877801328897, 470104.2198900606017560 5118817.9989861352369189, 470104.4689489488955587 5118818.1267635934054852, 470104.7634732913575135 5118818.1801844155415893, 470105.1260466062813066 5118818.2540330011397600, 470105.3785245955805294 5118818.2867654915899038, 470105.5785581194795668 5118818.3208900196477771, 470105.6056511744973250 5118818.3518560584634542, 470105.7439430109225214 5118818.5157791674137115, 470106.1222014605882578 5118818.9227604018524289, 470106.1284411964588799 5118818.9288233062252402, 470106.5464310075039975 5118819.3529041307047009, 470106.6427871120977215 5118819.4557428201660514, 470106.9725862752529792 5118819.7590857371687889, 470107.2358966815518215 5118820.0292196488007903, 470107.3813201090088114 5118820.1652430314570665, 470107.7115402040653862 5118820.5050115799531341, 470107.8513211797690019 5118820.6428627371788025, 470107.9793149215984158 5118820.7796726794913411, 470108.2898759883246385 5118820.8659558929502964, 470108.7934529126505367 5118820.9850132437422872, 470108.7981621584622189 5118820.9858465781435370, 470109.2699249187135138 5118821.1631668051704764, 470109.3070729986648075 5118821.1810790058225393, 470109.3527875082800165 5118821.2000940730795264, 470109.9645157544873655 5118821.5076951645314693, 470110.1974891899735667 5118821.6001068241894245, 470110.7554016472422518 5118822.0311174439266324, 470110.8268425106653012 5118822.0754088321700692, 470110.8854601128841750 5118822.1064947908744216, 470111.0442466789390892 5118822.1741034435108304, 470111.6637302815215662 5118822.5160459149628878, 470111.9044354973593727 5118822.7224536677822471, 470112.6635671497206204 5118823.2118344735354185, 470112.7762635055114515 5118823.2531422041356564, 470113.2037214054143988 5118823.4702636497095227, 470113.6503211875096895 5118823.7370715551078320, 470113.8005417566164397 5118823.8134555220603943, 470114.3559025689610280 5118824.2598237618803978, 470114.7022687001735903 5118824.4516086615622044, 470114.7455883345683105 5118824.4785579210147262, 470114.7686220881296322 5118824.4913061847910285, 470115.0385442765546031 5118824.6231620842590928, 470115.2785700320964679 5118824.7110700113698840, 470115.7130730836652219 5118824.9046156294643879, 470115.8580828186823055 5118824.9604245256632566, 470116.3561672090436332 5118825.1818804172798991, 470116.3601133818156086 5118825.1838789815083146, 470116.8392262525740080 5118825.3589283796027303, 470117.2628206278895959 5118825.4522381983697414, 470117.7481275261379778 5118825.6386371543630958, 470117.9316104652243666 5118825.7231691433116794, 470118.1074696420691907 5118825.8146983087062836, 470118.1558968161698431 5118825.8439600970596075, 470118.3971190098091029 5118825.9368473896756768, 470118.8981731848907657 5118826.1772461561486125, 470119.1421600079047494 5118826.2495983913540840, 470120.1626723508816212 5118826.7834279658272862, 470120.3161882558488287 5118826.8732619183138013, 470120.6811356636462733 5118826.9952017450705171, 470121.2132649790146388 5118827.1916402494534850, 470121.4412132326397114 5118827.2878871588036418, 470121.8751262659206986 5118827.3755624284967780, 470122.5541000029770657 5118827.5450606159865856, 470122.6109780974802561 5118827.5619795471429825, 470123.0628913493128493 5118827.6682563703507185, 470123.2545171005185694 5118827.7623121105134487, 470123.4794325226685032 5118827.8536972021684051, 470124.2233032326330431 5118828.3904139278456569, 470124.6726524920086376 5118828.6019103163853288, 470124.7772104062023573 5118828.6251227520406246, 470125.4679265323793516 5118828.8309835810214281, 470125.4842615755042061 5118828.8348530335351825, 470126.2114965038490482 5118829.0534505276009440, 470126.3170053007197566 5118829.0868345042690635, 470127.0258996635093354 5118829.2561796251684427, 470127.1156837421003729 5118829.2802204517647624, 470128.2414005553000607 5118829.4662264306098223, 470128.7995893471525051 5118829.5729518197476864, 470129.5535286433878355 5118829.5133186616003513, 470130.3326304581714794 5118829.4704850837588310, 470130.4531360376277007 5118829.6323407413437963, 470130.9131522001116537 5118830.2832449497655034, 470131.4807938825688325 5118831.0468477513641119, 470131.5795639660209417 5118831.1763062002137303, 470131.5852710003382526 5118831.1842278456315398, 470132.0660568301100284 5118831.5096190152689815, 470133.0074035015422851 5118832.0047203190624714, 470133.5397461864049546 5118832.3090269956737757, 470134.1091705624712631 5118832.4657007968053222, 470134.8667357692611404 5118832.7107125911861658, 470135.0070288327406161 5118832.7264800304546952, 470135.8366359979845583 5118832.8658928731456399, 470136.1925644007278606 5118832.9010181846097112, 470136.6148086061002687 5118833.0372018301859498, 470137.6829881025478244 5118833.2454929593950510, 470137.6999727420625277 5118833.2462091073393822, 470138.1002574741141871 5118833.3596641421318054, 470138.2362781096599065 5118833.3885590955615044, 470138.3026565329055302 5118833.3992027360945940, 470138.4352445058757439 5118833.4304719353094697, 470138.5628606181708165 5118833.4729731138795614, 470139.0994588692556135 5118833.5923083117231727, 470139.6537214833078906 5118833.7426714831963181, 470139.6634569473098963 5118833.7440530210733414, 470139.6823303151177242 5118833.7460600985214114, 470139.8435325486934744 5118833.7517129871994257, 470140.4381945325876586 5118833.8095402056351304, 470140.6237811497994699 5118833.8208547439426184, 470141.0344338514260016 5118833.9188575800508261, 470141.2467008404200897 5118833.9573634974658489, 470141.5852745854645036 5118834.0528588956221938, 470141.6582342667970806 5118834.0839407360181212, 470141.8255143518326804 5118834.1344209983944893, 470142.3657438528025523 5118834.2548635583370924, 470142.6169060925021768 5118834.2962667141109705, 470142.9384129293612204 5118834.3937198985368013, 470143.1940087045659311 5118834.4948036652058363, 470143.4868972867261618 5118834.5678844843059778, 470143.7055512530496344 5118834.6340609462931752, 470144.3689683609991334 5118834.7419774923473597, 470144.6101000356720760 5118834.8104863530024886, 470144.6284052168484777 5118834.8121630176901817, 470145.2892640305217355 5118834.9616406634449959, 470145.7721979327034205 5118835.0514449151232839, 470145.9377275055157952 5118835.1026580482721329, 470146.3080416555749252 5118835.2020418373867869, 470146.5179018228081986 5118835.2970219217240810, 470146.8315771474735811 5118835.3620040006935596, 470147.0261969302664511 5118835.4157014377415180, 470147.1241749667678960 5118835.4515679934993386, 470147.6535516006988473 5118835.6123254736885428, 470147.8691626153886318 5118835.6894936151802540, 470148.1487433006404899 5118835.7554216366261244, 470148.7480151226627640 5118835.9173462018370628, 470148.7838920823414810 5118835.9301556032150984, 470148.8432799732545391 5118835.9567342633381486, 470148.9197355740470812 5118835.9755080118775368, 470149.3535202054772526 5118836.1187276467680931, 470149.5737021631794050 5118836.1702347341924906, 470149.6623308009584434 5118836.1827830448746681, 470150.1656998585676774 5118836.2864430984482169, 470150.6143102994537912 5118836.2965040374547243, 470151.0098423669114709 5118836.3559779580682516, 470151.1453937339829281 5118836.3874038038775325, 470151.4519144050427713 5118836.4790344266220927, 470151.6905151675455272 5118836.5053580263629556, 470151.9404376325546764 5118836.5828683944419026, 470152.2226050281897187 5118836.6535713616758585, 470152.7489828299731016 5118836.7340109562501311, 470152.8424098209361546 5118836.7530791591852903, 470153.3869907215121202 5118836.8428955003619194, 470153.5071781424921937 5118836.8710422832518816, 470153.5310825029737316 5118836.8747784504666924, 470153.6408050571917556 5118836.8975281082093716, 470154.3537472895695828 5118837.1469732569530606, 470154.4342623140546493 5118837.1652423413470387, 470154.5145558223011903 5118837.1890916712582111, 470154.5481177133624442 5118837.1970493094995618, 470154.5847080265521072 5118837.2042961502447724, 470155.0202606115490198 5118837.2653110604733229, 470155.1545037149917334 5118837.2609197879210114, 470155.9195909791160375 5118837.3121833037585020, 470156.0569024720462039 5118837.3354215966537595, 470156.6841602589120157 5118837.3450763775035739, 470156.9741454290924594 5118837.3790444759652019, 470157.5588502416503616 5118837.3709368836134672, 470157.9685852369293571 5118837.4270214810967445, 470158.0597282389062457 5118837.4471131917089224, 470158.1542640926199965 5118837.4472125032916665, 470158.2995684093330055 5118837.4567441605031490, 470158.5752397163305432 5118837.4883568268269300, 470158.6828856320935301 5118837.5154466396197677, 470158.9732155441306531 5118837.5654885293915868, 470159.3193027642555535 5118837.5971570005640388, 470159.4224713157746010 5118837.6101342868059874, 470159.9531333080958575 5118837.5977873317897320, 470160.0630936728557572 5118837.6009671743959188, 470160.4143224778235890 5118837.5541098536923528, 470160.7380978381261230 5118837.5799287762492895, 470160.9687839231919497 5118837.5629350300878286, 470161.5094033891218714 5118837.5531791504472494, 470161.7867850738111883 5118837.4913505529984832, 470162.2463757249643095 5118837.4173527136445045, 470162.4555643986095674 5118837.3715118942782283, 470162.5171057265833952 5118837.3697364181280136, 470162.8466961273225024 5118837.4012549305334687, 470163.2601742323604412 5118837.4088871488347650, 470163.6120380443171598 5118837.4461272051557899, 470163.9486325088073500 5118837.4586307723075151, 470164.4678455661633052 5118837.5466483645141125, 470164.8000216344371438 5118837.5829548602923751, 470165.1977941739605740 5118837.6943110115826130, 470165.2504917632904835 5118837.7135901264846325, 470165.4426121418946423 5118837.7967853248119354, 470165.4584519026684575 5118837.8026964599266648, 470166.0493708805879578 5118838.1043429281562567, 470166.3996206868323497 5118838.3250227533280849, 470166.6230014498578385 5118838.4511259682476521, 470167.2132467026240192 5118838.8524269685149193, 470167.2140331511036493 5118838.8520818939432502, 470167.6357830269844271 5118838.7031536521390080, 470168.0495872682658955 5118838.5399617943912745, 470168.5960481368238106 5118838.4012925112619996, 470169.2721650358289480 5118838.2003793958574533, 470169.6036230193567462 5118838.0947676962241530, 470169.9927536636241712 5118838.1274256734177470, 470170.6994281034567393 5118838.1587635641917586, 470170.9620325724827126 5118838.1650323029607534, 470171.3830515442532487 5118838.2009265199303627, 470171.5465380621026270 5118838.2079964689910412, 470172.2695403318502940 5118838.2478210907429457, 470172.6492414486710913 5118838.2307383026927710, 470172.7995751707348973 5118838.2256696792319417, 470173.4485264432732947 5118838.1469978019595146, 470173.5542077521677129 5118838.2322800243273377, 470174.1775477503542788 5118838.7050005439668894, 470174.3693641565041617 5118838.8603487154468894, 470174.7369679918629117 5118839.1314363479614258, 470174.7421170863672160 5118839.1457966687157750, 470174.8748123021214269 5118839.5548353800550103, 470175.1406865491298959 5118839.9119345638900995, 470175.2887151243048720 5118840.1339984890073538, 470175.6006085993140005 5118840.5670682052150369, 470175.6112881380249746 5118840.5839075082913041, 470175.9706011666567065 5118841.1039122091606259, 470175.9933500598999672 5118841.1326257390901446, 470176.3399393218569458 5118841.6339331855997443, 470176.3581877099932171 5118841.6647193646058440, 470176.7194216827047057 5118842.1846107924357057, 470176.7296182432328351 5118842.2018062565475702, 470177.1506996082025580 5118842.7741787256672978, 470177.1630509906681255 5118842.7879237057641149, 470177.5389752131304704 5118843.2719559650868177, 470177.9061701361788437 5118843.6813463903963566, 470177.9672018812270835 5118843.7913637142628431, 470178.3837726474157535 5118844.4090146478265524, 470178.4115617505740374 5118844.4663262888789177, 470178.6016836565686390 5118844.7899262029677629, 470178.8679082416347228 5118845.3350598588585854, 470178.9076033378951252 5118845.4670244529843330, 470179.0692196870222688 5118845.8139276560395956, 470179.0724876914173365 5118845.8426963072270155, 470179.0879055423429236 5118846.0388490641489625, 470179.1405801731161773 5118846.3547583781182766, 470179.1800349643453956 5118846.5199363902211189, 470179.2169530807295814 5118846.8428671862930059, 470179.2452609413885511 5118846.9522190690040588, 470179.3439209741191007 5118847.6088884547352791, 470179.4983114697970450 5118848.2980424407869577, 470179.5089058846933767 5118848.3293538596481085, 470179.4030947866267525 5118849.2523426059633493, 470179.4278874081210233 5118849.9079353595152497, 470179.4343716907897033 5118849.9496504049748182, 470179.4788884017034434 5118850.4145467961207032, 470179.5113743342226371 5118850.5644330605864525, 470179.5851392750046216 5118851.0386924305930734, 470179.6275292412028648 5118851.1693377774208784, 470179.7815862298593856 5118851.7625567652285099, 470179.7924907987471670 5118851.8181276256218553, 470179.8428824072470888 5118851.9848552402108908, 470179.8500340011669323 5118852.1493888022378087, 470179.8431390019832179 5118852.5563122080639005, 470179.8764533064095303 5118852.8662418518215418, 470179.9021349145332351 5118853.2579877115786076, 470179.9420565872569568 5118853.5223812898620963, 470179.9497490875073709 5118853.8637488689273596, 470179.9528170891571790 5118853.8995718508958817, 470179.9286877622362226 5118854.4806132316589355, 470179.9299099485506304 5118854.5092909960076213, 470179.9301825803122483 5118855.0191699191927910, 470179.8865229799994268 5118855.7260569818317890, 470179.9200983810587786 5118855.8789856387302279, 470179.9268155653262511 5118855.9907641373574734, 470179.8840107707073912 5118856.7453832896426320, 470179.8633985391352326 5118856.9623127179220319, 470179.9101480425451882 5118857.3674881467595696, 470179.9278362622135319 5118857.5955859916284680, 470179.8719264566316269 5118857.8770581576973200, 470179.6834683964843862 5118858.6692654862999916, 470179.5294579709297977 5118859.1917571676895022, 470179.6269834375125356 5118859.5097696967422962, 470179.8389584776596166 5118860.2970679821446538, 470180.0014505131985061 5118861.0635203123092651, 470180.1158215521136299 5118861.8766191927716136, 470180.1219247903209180 5118861.9552870886400342, 470180.3675444907858036 5118862.5744542488828301, 470180.5053610203904100 5118862.9727089768275619, 470180.5496728606522083 5118863.0847444450482726, 470180.6307780602946877 5118863.2597988108173013, 470180.7289400600129738 5118863.4984041666612029, 470180.8363635570276529 5118863.6765506798401475, 470180.9703141737263650 5118864.2747289724647999, 470181.0615039587719366 5118864.7096322812139988, 470181.1650830310536548 5118865.0071829240769148, 470181.2508560731657781 5118865.5527576431632042, 470181.2952976850210689 5118865.8108037058264017, 470181.3782297885045409 5118866.4394131032750010, 470181.3815590027370490 5118866.4708731882274151, 470181.3878832600894384 5118866.5241396874189377, 470181.4601648785173893 5118866.6569489603862166, 470181.6722841528826393 5118866.9931467222049832, 470181.8706047434825450 5118867.3369615785777569, 470182.1521721782628447 5118867.7827128889039159, 470182.3341222974122502 5118868.1298777647316456, 470182.7530922299483791 5118868.7346321567893028, 470182.7991901198984124 5118868.8140935832634568, 470183.2407226705690846 5118869.4145353343337774, 470183.4595567898941226 5118869.6535876104608178, 470183.7205828938167542 5118869.9790743952617049, 470184.1581187162664719 5118870.4200117317959666, 470184.2055954923853278 5118870.4729969017207623, 470184.5094150441000238 5118870.7557106688618660, 470184.6627576545579359 5118870.8844428416341543, 470184.8337817439460196 5118871.0105676138773561, 470184.9666525724460371 5118871.0963107664138079, 470184.9900464424863458 5118871.1145087555050850, 470185.1109418922569603 5118871.1992447143420577, 470185.1136454743100330 5118871.2013506153598428, 470185.1272487566457130 5118871.2134176120162010, 470185.2931209805537947 5118871.3463310729712248, 470185.3383495491580106 5118871.3899678317829967, 470185.6377239038702101 5118871.6442139875143766, 470185.9849736142787151 5118871.9024934740737081, 470186.2015539092826657 5118872.0384537391364574, 470186.7337006204179488 5118872.3923860015347600, 470186.7949864739784971 5118872.4190467176958919, 470187.4346221742453054 5118872.7175538344308734, 470187.9635758287622593 5118872.9818517528474331, 470188.2257026336155832 5118873.0701620997861028, 470188.5529786573606543 5118873.1954448586329818, 470188.6241929877432995 5118873.2393434522673488, 470189.4637274146080017 5118873.8054396249353886, 470189.4760406863642856 5118873.8142454763874412, 470189.8346378836431541 5118874.2598250573500991, 470189.9363072702544741 5118874.3934683380648494, 470190.8675050329184160 5118874.8628237238153815, 470191.7724113906733692 5118875.3554490907117724, 470191.8008112808456644 5118875.3721380326896906, 470192.4272300230804831 5118875.7138063637539744, 470192.7293123549898155 5118875.8605452077463269, 470192.7663873070268892 5118875.8683454599231482, 470192.9973241495899856 5118875.9243575371801853, 470193.3011106046615168 5118875.9882275126874447, 470193.3356508139986545 5118876.0041313627734780, 470193.5364159329910763 5118876.1041049566119909, 470194.0497995736077428 5118876.3403950491920114, 470194.3337735795066692 5118876.4605929870158434, 470194.5318666651146486 5118876.5630671177059412, 470195.2699723027180880 5118876.7392580583691597, 470195.3773541613481939 5118876.7579566370695829, 470196.0752729510422796 5118877.1098286472260952, 470196.1228492896771058 5118877.1301139341667295, 470196.7741849146550521 5118877.4328282913193107, 470196.9542256633867510 5118877.5272321971133351, 470197.1033860294264741 5118877.5850723404437304, 470197.3504787114798091 5118877.6460166880860925, 470197.6596665420220234 5118877.6910895667970181, 470197.6763052830938250 5118877.6946316789835691, 470198.1379197904025204 5118877.7618867503479123, 470198.5972382103209384 5118877.7752663558349013, 470199.0169102217187174 5118877.8439157418906689, 470199.0685743638896383 5118877.8479886967688799, 470199.3651440007379279 5118877.8965702718123794, 470199.7524176146835089 5118878.0013412144035101, 470199.7848268041270785 5118878.0144883301109076, 470200.5590382287045941 5118878.2537871515378356, 470200.7324282586923800 5118878.3140747239813209, 470201.1157023867708631 5118878.3748874207958579, 470201.2832843028008938 5118878.4075177097693086, 470201.5733904088265263 5118878.4428272880613804, 470201.8188390946015716 5118878.4550434937700629, 470201.9435972387436777 5118878.4679243844002485, 470202.3760133507894352 5118878.4738608598709106, 470203.0267774383537471 5118878.4248784296214581, 470203.1311663907836191 5118878.4001417811959982, 470204.1344480654224753 5118878.4504515128210187, 470204.3868634045938961 5118878.4082756936550140, 470204.8816994790104218 5118878.4148240434005857, 470205.0567966938833706 5118878.4266661107540131, 470205.2771544090937823 5118878.4577183052897453, 470205.3823148745577782 5118878.4647758873179555, 470206.1098883909871802 5118878.6088956575840712, 470206.1366415777010843 5118878.6157645629718900, 470206.9002305121975951 5118878.7379342745989561, 470207.0417278649401851 5118878.7525986451655626, 470207.3786512942751870 5118878.8387897359207273, 470207.5684980230871588 5118878.8380824504420161, 470208.0802405923604965 5118878.9020958859473467, 470208.4542708793305792 5118878.9208212206140161, 470208.9087042575702071 5118878.9777706721797585, 470209.3733328535454348 5118879.0099716391414404, 470209.7352911465568468 5118879.0893890187144279, 470209.7520763703505509 5118879.0943504413589835, 470209.8790774891385809 5118879.1196815175935626, 470209.8855917023611255 5118879.1213465062901378, 470209.9998172864434309 5118879.1337926918640733, 470210.0075892650638707 5118879.1336462991312146, 470210.8058422378962860 5118879.1615885766223073, 470211.3104543438530527 5118879.1510956743732095, 470211.6124938384164125 5118879.1336852042004466, 470212.2518425498274155 5118879.4481720142066479, 470213.4532921929494478 5118879.7729602288454771, 470213.6193493349128403 5118879.8398665543645620, 470214.2134417155757546 5118879.8641648050397635, 470215.0839494242682122 5118880.0074240276589990, 470215.1352950704167597 5118880.0236018113791943, 470216.1500291543197818 5118880.1908491598442197, 470216.4931156810489483 5118880.3122179079800844, 470216.7963567340048030 5118880.3331801630556583, 470217.3471668957499787 5118880.4246197883039713, 470217.5965353860519826 5118880.4422410726547241, 470217.8135550682200119 5118880.4374031024053693, 470218.3866056738188490 5118880.6013339376077056, 470219.5202620036434382 5118880.6343860542401671, 470219.6251873968867585 5118880.6665477743372321, 470220.4497611616970971 5118880.8691028673201799, 470220.6354061689344235 5118880.9076024424284697, 470221.1138089573360048 5118881.0927922930568457, 470221.4314156196778640 5118881.2029314497485757, 470221.9925668359501287 5118881.5130367651581764, 470222.1806989717297256 5118881.5927902981638908, 470222.2924305935739540 5118881.6336462507024407, 470222.3492661971249618 5118881.6512801200151443, 470222.5810223459848203 5118881.7278670985251665, 470223.0095154453883879 5118881.8244024440646172, 470223.0965036061825231 5118881.8340327497571707, 470223.4275108940782957 5118881.8756360132247210, 470223.7333810668787919 5118881.8853379525244236, 470224.0292279334389605 5118881.8722614590078592, 470224.0683947585639544 5118881.8669897560030222, 470224.4950785859255120 5118881.9418780533596873, 470224.7301199475768954 5118881.9543159520253539, 470225.4805378162418492 5118882.3331809276714921, 470225.5831731292419136 5118882.3809855254366994, 470226.1412636423483491 5118882.6745698628947139, 470226.1996007196721621 5118882.7017037337645888, 470226.7781668160459958 5118883.0072096129879355, 470226.7937063681310974 5118883.0147635303437710, 470227.2738048655446619 5118883.2798477420583367, 470227.3220226054545492 5118883.3043848844245076, 470227.8317263122298755 5118883.5982220433652401, 470227.8506244781892747 5118883.6074668504297733, 470228.0693201902322471 5118883.7333975611254573, 470228.4496516493964009 5118883.9190752888098359, 470228.4499907571589574 5118883.9193885633721948, 470229.1780221193330362 5118884.4275022819638252, 470229.5632644451688975 5118884.7468948895111680, 470229.7414441859582439 5118884.8810156602412462, 470230.4307404214632697 5118885.4738298486918211, 470230.5528536839410663 5118885.5729256151244044, 470231.0869065317674540 5118886.1992265889421105, 470231.2268397209118120 5118886.3546013860031962, 470231.4653092983062379 5118886.7085390202701092, 470231.4772572146030143 5118886.7285356437787414, 470231.4989793954882771 5118886.7698951456695795, 470231.5431864636484534 5118886.8669287972152233, 470231.5779334833496250 5118886.8898728843778372, 470231.8526287461281754 5118887.1011918587610126, 470232.4164062271593139 5118887.4426903631538153, 470232.5426884698681533 5118887.5270067192614079, 470233.0767739306320436 5118887.8503393139690161, 470233.2045020501245745 5118887.9198629539459944, 470233.2201885461690836 5118887.9290094831958413, 470233.9120732185547240 5118888.1598159177228808, 470233.9536269574309699 5118888.1751020224764943, 470234.7488730733748525 5118888.4550382923334837, 470235.2124102519010194 5118888.6431394349783659, 470235.5600974560948089 5118888.7792564202100039, 470236.3686242793337442 5118889.1255407081916928, 470236.5798702939064242 5118889.2358251549303532, 470236.7465139155974612 5118889.3324125697836280, 470236.8282162933028303 5118889.3785846577957273, 470237.1368235202971846 5118889.6020852494984865, 470237.2022854285314679 5118889.7426378736272454, 470237.6187659273273312 5118890.2532075401395559, 470237.8048165495274588 5118890.4849610170349479, 470238.7506730103632435 5118891.2968266885727644, 470238.8767501750262454 5118891.3844352429732680, 470239.6365645517362282 5118891.9268399532884359, 470239.6569938739412464 5118891.9425072055310011, 470240.0038902963860892 5118892.1522112628445029, 470240.0998579498264007 5118892.2376653002575040, 470240.7586747044697404 5118892.8406814010813832, 470240.8781803451129235 5118892.9171140110120177, 470241.5305211379891261 5118893.3455634508281946, 470241.9125129228341393 5118893.5386838223785162, 470242.3231401618104428 5118893.7520300420001149, 470243.1412618322647177 5118894.1637043552473187, 470243.1681021951371804 5118894.1775566348806024, 470243.2688666632166132 5118894.6371359638869762, 470243.3272139864275232 5118894.8901687422767282, 470243.6022238435689360 5118896.1257452610880136, 470243.7423731935559772 5118896.7254647063091397, 470243.9162808676483110 5118896.8868793761357665, 470244.3735361383296549 5118897.2627229718491435, 470245.0001338714500889 5118897.7899864101782441, 470245.1831967153120786 5118897.9171092296019197, 470245.2335627188440412 5118897.9532758742570877, 470245.2910777918878011 5118897.9900844600051641, 470245.4959599217982031 5118898.1098309392109513, 470245.6913700614823028 5118898.3686891580000520, 470246.2144384224666283 5118898.9017424248158932, 470246.6665885710972361 5118899.4108313694596291, 470246.9200053533422761 5118899.7410619575530291, 470247.1982825891464017 5118899.9394741412252188, 470247.6973398258560337 5118900.3587257778272033, 470247.7669099133345298 5118900.4254919523373246, 470248.2512892062659375 5118900.7972186813130975, 470248.3278089331579395 5118900.8620512569323182, 470248.5505379324313253 5118901.0079978229478002, 470248.9229679277632385 5118901.2131286589428782, 470248.9964937207987532 5118901.2618138045072556, 470249.4212651167763397 5118901.5111438082531095, 470249.4839780969778076 5118901.5411514369770885, 470249.5515966775128618 5118901.5689875697717071, 470249.5869756492320448 5118901.5780018148943782, 470250.2597668014350347 5118901.7919527525082231, 470250.2659873150405474 5118901.7935390602797270, 470250.4288944876752794 5118901.8399619366973639, 470250.7531854373519309 5118901.8751236917451024, 470250.7995140081038699 5118901.8788322089239955, 470251.3542864632909186 5118901.9385037422180176, 470251.4489007883821614 5118901.9512434108182788, 470251.9016648702090606 5118901.9514571949839592, 470251.9172120369039476 5118901.9479440851137042, 470252.4446877735317685 5118901.8433582903817296, 470252.8154052031459287 5118902.0634319605305791, 470253.0522206901805475 5118902.1892967913299799, 470253.3467823333339766 5118902.3635197244584560, 470253.4666677894419990 5118902.4195651300251484, 470253.5055293485638686 5118902.4355207979679108, 470253.5354991141357459 5118902.4453980829566717, 470253.7492896178155206 5118902.5217534424737096, 470253.7942387752700597 5118902.5318710952997208, 470254.0597238477785140 5118902.9909203639253974, 470254.2649518639664166 5118903.4264864912256598, 470254.4327231264906004 5118903.6760592758655548, 470255.7409572337637655 5118903.8294296907261014)'
line = shapely.wkt.loads(linewkt)

linespliner = GeoSmoothing(spl_smpar=5, spl_order=3)
smooth = linespliner.smoothObj(line)

# --------------------------------------------------------
# Do a little show and tell with plotting and whatnot
# --------------------------------------------------------
fig = plt.figure(1, figsize=(10, 10))
ax = fig.gca()

ax.plot(*line.xy, color='#FF0000', linewidth=1, alpha=0.5)
ax.plot(*smooth.xy, color='#00FF00', linewidth=1, alpha=0.5)

plt.autoscale(enable=True)
plt.show()

I think a lot of this is because I haven't taken the time to understand how splev and splprep work but I'm hoping between the two of us we can figure this out.

@MattReimer
Copy link
Author

I did a bit more testing. I tried combinations for s=0...10 and n=1...3

It seems like the only time the start and endpoint are exactly the same are when you have s=0, order=1.

@cayetanobv
Copy link
Member

Hi @MattReimer ,

Start and endpoint have exactly the same value when spl_smpar=0, spl_order=1. But you can control more smoothing in output geometry increasing the degree of spline (spl_order=3 is a cubic spline). If your coordinate system is UTM (meters), the error is so small that it should not be taken into account (1e-10 meters). Changing spl_smart is not a good idea if you want to preserve original position of endpoints. Take into account that I am not precomputing a weighted matrix to use with the smoothing condition parameter (spl_smpar).

In any case, I preferred (for geospatial use cases) to keep default values of spl_smpar=0 and spl_order=2 because they avoid problems of excessive detachment from reality. You can see screenshot with one of your endpoints computed with quadratic spline (red) and cubic spline (purple) - original line is light blue:

image

I would happily accept improvement proposals in the library via PR.

Thaks for all!

Cayetano Benavent

@MattReimer
Copy link
Author

This makes total sense. I was willing to accept deviation from the vertices for spl_smpar > 0 as long as the start and end points matched up but I see now that it is more complicated.

I'd like to know more about the weighted smoothing matrix so I'll look into that the next chance I get. Thanks for your attention to this. I'll let you know when I have something to show.

@cayetanobv
Copy link
Member

@MattReimer thank you very much for your interest. I'll keep open this issue in case something new comes up.

@MattReimer MattReimer changed the title Protect line endpoints? Centerline: Protect line endpoints? Jan 19, 2017
@MattReimer MattReimer changed the title Centerline: Protect line endpoints? Protect line endpoints? Jan 19, 2017
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

2 participants