Create dict from array or list OR just parse the list for X and Y coordinates - python-3.x

I have 3000 lines of data like this:
['OFFD.271818,271818,"LINESTRING (16.303895355263016 48.18772778239529, 16.304571765172827 48.18758202488568, 16.30482300975865 48.18755484403183, 16.305031079294384 48.187546649202545, 16.30536730486924 48.187533407177206, 16.307523452290432 48.18753396398144, 16.309072536732444 48.18748514596115, 16.312777938045286 48.18734458451529, 16.313426882251083 48.18727411748434, 16.315405366265555 48.186920966444205, 16.316609208646593 48.18670268519608, 16.317260447683868 48.18652861710351, 16.31853471535412 48.186166775088815)",U4,4,U-Bahn,']
I want using matplotlib to create a plot, but I need X and Y coordinates.
The Targe is: U4 (from the line)
Coordinates are:
16.303895355263016 48.18772778239529, 16.304571765172827 48.18758202488568, 16.30482300975865 48.18755484403183, 16.305031079294384 48.187546649202545, 16.30536730486924 48.187533407177206, 16.307523452290432 48.18753396398144, 16.309072536732444 48.18748514596115, 16.312777938045286 48.18734458451529, 16.313426882251083 48.18727411748434, 16.315405366265555 48.186920966444205, 16.316609208646593 48.18670268519608, 16.317260447683868 48.18652861710351, 16.31853471535412 48.186166775088815
I do not get how to parse this string with numpy and create the dataset:
U4: coordinates for X: ... and for Y:....
Any hints?

Related

How to avoid overlapping xticklabels in seaborn plot when spacing is narrow

I have the following dataframe:
,ENC,EPM,CPFNN,vMLP
cg19493601,0,0,0,2
cg17435445,0,0,0,2
cg02319392,0,0,0,2
cg04672495,0,0,0,2
cg09089913,0,0,0,2
cg21308111,0,0,0,2
cg03569073,0,0,0,2
cg26750487,0,0,0,1
cg05542262,0,0,0,2
cg19191454,0,0,0,2
cg20160885,0,0,0,2
cg02122467,0,0,0,2
cg27021986,0,0,0,2
cg22671421,0,0,0,2
cg06396762,0,0,0,2
cg03406626,0,0,0,2
cg02376827,0,0,0,2
cg04157865,0,0,0,2
cg14582226,0,0,0,2
cg19572264,0,0,0,2
cg10979436,0,0,0,1
cg15594550,0,0,0,1
cg06623057,0,0,1,1
cg14231987,0,0,0,2
cg14029283,0,0,0,2
cg24473385,0,0,0,1
cg19814830,0,0,0,2
cg14283099,0,0,0,2
cg16092645,0,0,0,2
cg02731774,0,0,0,2
cg19615721,0,0,0,2
cg18220632,0,0,0,1
cg25123102,0,0,0,2
cg04657715,0,0,0,1
cg21115608,0,0,0,2
cg13545874,0,0,0,2
cg11969637,0,0,0,1
cg03400437,0,0,0,2
cg25604067,0,0,0,1
cg20067598,0,0,0,2
cg17578235,0,0,1,1
cg05190577,0,0,0,2
cg04937422,0,0,0,2
cg27390496,0,0,0,2
cg18283673,0,0,0,1
cg01105403,0,0,0,1
cg06315607,0,0,0,2
cg27513574,0,0,0,2
cg10593416,0,0,0,1
cg19523338,0,0,0,1
cg10242862,0,0,0,2
cg01167177,0,0,0,1
cg18599069,0,0,0,2
cg20331814,0,0,0,2
cg10322510,0,0,0,2
cg09120267,0,0,0,1
cg05490132,0,0,0,1
cg02289168,0,0,0,1
cg09241267,0,0,0,1
cg03665605,0,0,0,1
cg20018782,0,0,0,1
cg13018197,0,0,0,2
cg24275159,0,0,0,2
cg14210236,0,0,0,2
cg03417342,0,0,0,1
cg25483123,0,0,0,2
cg03672854,0,0,0,2
cg26674929,0,0,0,2
cg16717099,0,0,0,2
cg14566393,0,0,0,1
cg18685561,0,0,0,1
cg18725681,0,0,0,2
cg13062821,0,0,0,1
cg15962547,0,0,0,2
cg19563510,0,0,0,1
cg25697726,0,0,0,1
cg10068989,0,0,0,2
cg04907885,0,0,0,2
cg16494530,0,0,0,1
cg09289712,0,0,0,2
cg18994446,0,0,0,1
cg10445447,0,0,0,2
cg11762629,0,0,0,2
cg07065737,0,0,0,1
cg14688108,0,1,1,1
cg14989522,0,0,0,1
cg18751682,0,0,0,2
cg17291435,0,0,0,2
cg20792512,0,0,0,2
cg21522303,0,0,0,2
cg09594069,0,0,0,2
cg03523550,0,0,0,2
cg08207707,0,0,0,2
cg06622408,0,0,0,2
cg07359633,0,0,0,2
cg19733833,0,0,1,2
cg10172801,0,0,0,1
cg14911690,0,0,0,2
cg01914744,0,0,0,2
cg20430572,0,0,0,1
cg05904213,0,0,0,2
cg19182423,0,0,0,1
cg15911859,0,0,0,2
cg25767192,0,0,0,2
cg03963391,0,0,0,2
cg25612710,0,0,0,2
cg22636108,0,0,0,2
cg21285525,0,0,1,1
cg11332928,0,0,0,2
cg11480264,0,0,0,1
cg09176740,0,0,0,1
cg14583871,0,0,0,2
cg12845923,0,0,0,1
cg06534313,0,0,0,1
cg04930858,0,0,0,1
cg04281268,0,0,0,2
cg17035899,0,0,1,1
cg18686155,0,0,0,2
cg04651042,0,0,0,2
cg18767088,0,0,1,2
cg10025443,0,0,0,2
cg01475538,0,0,1,1
cg24311272,0,0,0,2
cg18500674,0,0,0,2
cg21748418,0,0,0,1
cg11915997,0,0,0,2
cg03727342,0,0,0,2
cg09073441,0,0,0,2
cg21153962,0,0,0,2
cg02797548,0,0,0,2
cg27388777,0,0,0,2
cg17868287,0,0,0,2
cg01531388,0,0,0,2
cg07768201,0,0,0,2
cg26386968,0,1,1,1
cg14731657,0,0,0,2
cg00155063,0,0,1,2
cg09817427,0,0,0,2
cg22691746,0,0,0,2
cg09571376,0,0,0,1
cg21383280,0,0,0,1
cg21019315,0,0,0,2
cg07824824,0,0,0,1
cg03782778,0,0,0,2
cg20513721,0,0,0,2
cg04757012,0,0,0,2
cg09967192,0,0,0,2
cg26925114,0,0,0,1
cg19412667,0,0,0,2
cg13939664,0,0,0,2
cg15766595,0,0,0,2
cg12041266,0,0,0,2
cg07785447,0,0,0,2
cg13915354,0,0,0,1
cg15512534,0,0,0,1
cg24144083,0,0,1,1
cg17603502,0,0,0,2
cg11999631,0,0,0,2
cg26974111,0,0,1,1
cg09818930,0,0,0,2
cg19518388,0,0,0,2
cg07924892,0,0,0,2
cg03666316,0,0,0,2
cg26006440,0,0,0,2
cg24679567,0,0,0,1
cg15179515,0,0,0,2
cg22542751,0,0,0,2
cg18135796,0,0,0,2
cg22766230,0,0,0,1
cg18043157,0,0,0,1
cg10367023,0,0,0,2
cg07747661,0,0,0,1
cg00915818,0,0,0,2
cg21216268,0,0,0,2
cg09268672,0,0,0,1
cg00641009,0,0,0,2
cg21175685,0,0,0,2
cg09478268,0,0,0,1
cg07452625,0,0,0,2
cg08881785,0,0,0,1
cg18147605,0,0,0,2
cg15202378,0,0,0,2
cg07693657,0,0,0,1
cg02493205,0,0,0,1
cg08376310,0,0,0,2
cg18049142,0,0,0,2
cg16132219,0,0,0,2
cg09112760,0,0,0,2
cg20152891,0,0,0,2
cg12956472,0,0,0,1
cg10151901,0,0,0,2
cg26785154,0,0,0,1
cg01196079,0,0,0,1
cg10227919,0,0,0,1
cg17799601,0,0,0,1
cg22960907,0,0,0,2
cg20932768,0,0,0,2
cg10278931,0,0,0,1
cg13539424,0,0,0,1
cg10188732,0,0,0,2
cg18424968,0,0,0,2
cg13787272,0,0,0,2
cg08642716,0,0,0,2
cg01972418,0,0,0,2
cg21955796,0,0,0,2
cg09796320,0,0,0,1
cg00752480,0,0,0,1
cg20225546,0,0,0,2
cg05529157,0,0,0,1
cg21025501,0,0,0,2
cg24842597,0,0,0,1
cg16700779,0,0,1,2
cg23340104,0,0,0,2
cg03516318,0,0,0,2
cg09560650,0,0,0,1
cg06819687,0,0,0,2
cg00106074,0,0,0,2
cg21965516,0,0,0,1
cg01328119,0,0,0,2
cg13948585,0,0,0,2
cg05494465,0,0,0,2
cg22532475,0,0,0,1
cg00920348,0,0,0,2
cg20938572,0,0,0,2
cg21453831,0,0,0,2
cg04241652,0,0,0,2
cg02757572,0,0,0,2
cg02600349,0,0,0,2
cg02626667,0,0,0,1
cg00611495,0,0,0,1
cg00290373,0,0,0,2
cg07556829,0,0,0,2
cg04497611,0,0,0,2
cg18402615,0,0,0,2
cg18360825,0,0,0,1
cg03702919,0,0,0,2
cg26060489,0,0,0,2
cg13178766,0,0,0,2
cg00401972,0,0,0,1
cg11791710,0,0,0,2
cg19766441,0,0,0,2
cg19961480,0,0,0,2
cg01965950,0,0,0,1
cg19996355,0,0,0,2
cg23292266,0,0,0,2
cg25801502,0,0,0,1
cg22854549,0,0,0,2
cg02105326,0,0,0,2
cg06928993,0,0,0,2
cg08152564,0,0,0,2
cg03867759,0,0,0,2
cg18145196,0,0,0,1
cg08051076,0,0,0,1
cg20946369,0,0,0,1
cg22679120,0,0,0,2
cg21548029,0,0,0,2
cg16715692,0,0,0,1
cg22591433,0,0,0,2
cg13242468,0,0,0,2
cg23169614,0,0,0,2
cg12368612,0,0,0,2
cg19722639,0,0,0,2
cg05027085,0,0,0,2
cg02980621,0,0,0,2
cg10985993,0,0,0,2
cg18997875,0,0,0,2
cg02716556,0,0,0,2
cg01054478,0,0,0,1
cg26381783,0,0,0,2
cg25990363,0,0,0,2
cg17759806,0,0,0,2
cg18589102,0,0,0,2
cg16133088,0,0,0,2
cg04725507,0,0,0,2
cg26748945,0,0,0,2
cg26824709,0,0,0,1
cg25857710,0,0,0,2
cg01616215,0,0,0,2
cg02254554,0,0,0,2
cg06131936,0,0,1,1
cg00913799,0,0,0,2
cg23149687,0,0,0,2
cg25153196,0,0,0,1
cg24695614,0,0,1,1
cg08573355,0,0,0,2
cg02413370,0,0,0,1
cg05204798,0,0,1,1
cg16977596,0,0,0,2
cg09879895,0,0,0,2
cg08541521,0,0,0,2
cg04843615,0,0,0,2
cg00799631,0,0,0,2
cg02540094,0,0,0,2
cg11908557,0,0,0,2
cg06842071,0,0,0,1
cg01323274,0,0,0,2
cg05195017,0,0,0,1
cg05601917,0,0,1,1
cg27079740,0,0,0,1
cg13785536,0,0,0,2
cg22775138,0,0,0,2
cg26230417,0,0,0,2
cg14102055,0,0,0,1
cg07227926,0,0,0,2
cg12804441,0,0,0,2
cg14170181,0,0,0,2
cg06005098,0,0,0,2
cg18569885,0,0,0,1
cg27295716,0,0,0,2
cg06622725,0,0,0,2
cg27603366,0,0,0,2
cg20158796,0,0,0,2
cg14920696,0,0,0,2
cg25722423,0,0,0,2
cg22736354,0,0,0,2
cg03505427,0,0,0,1
cg01217204,0,0,0,2
cg09967647,0,0,0,2
cg22159421,0,0,0,2
cg19995828,0,0,0,2
cg23472930,0,0,0,2
cg00702008,0,0,0,1
cg25534294,0,0,0,1
cg27201301,0,0,0,2
cg25735887,0,0,0,2
cg06208926,0,0,0,1
cg05945782,0,0,0,2
cg01112249,0,0,0,1
cg12781568,0,0,0,2
cg04787317,0,0,0,2
cg07365960,0,0,0,2
cg15435996,0,0,0,1
cg20077393,0,0,0,2
cg15394350,0,0,0,2
cg07793849,0,0,0,2
cg06143732,0,0,0,2
cg17922215,0,0,0,2
cg21619814,0,0,0,1
cg03840496,0,0,0,1
cg00716309,0,0,0,1
cg07023324,0,0,0,1
cg15788149,0,0,1,1
cg02745321,0,0,0,1
cg17273683,0,0,0,1
cg10709593,0,0,0,2
cg25523538,0,0,0,2
cg08210342,0,0,0,1
cg07332683,0,0,0,1
cg14566475,0,0,0,1
cg26116495,0,0,0,2
cg12169365,0,0,0,2
cg02879662,0,0,0,2
cg03867475,0,0,0,2
cg03660500,0,0,0,2
cg22855900,0,0,0,2
cg00076998,0,0,0,2
cg21216010,0,0,0,2
cg22337605,0,0,0,2
cg24663541,0,0,0,2
cg08898442,0,0,0,1
cg17830959,0,0,0,2
cg25617230,0,0,1,1
cg01073605,0,0,0,2
cg07645736,0,0,0,2
cg17906269,0,0,0,2
cg01689641,0,0,0,2
cg21727214,0,0,0,1
ch.11.1543446R,0,0,0,2
cg12897947,0,0,0,2
cg02916525,0,0,0,2
cg20449382,0,0,0,2
cg27050747,0,0,0,1
cg08596000,0,0,0,2
cg15442907,0,0,0,1
cg02422902,0,0,0,2
cg20536512,0,0,0,2
cg15475080,0,0,0,2
cg22484737,0,0,0,2
cg20283971,0,0,0,2
cg08369436,0,0,1,1
cg03598440,0,0,0,1
cg20005056,0,0,0,1
cg09790502,0,0,0,2
cg00009916,0,0,0,1
cg03179043,0,0,0,1
cg04227079,0,0,0,1
cg26931862,0,0,0,1
cg07527324,0,0,0,2
cg26144458,0,0,0,2
cg02245998,0,0,0,1
cg20068496,0,0,0,2
cg04768927,0,0,0,2
cg08097877,0,0,0,1
cg03957204,0,0,0,1
cg07967210,0,0,0,2
cg11227822,0,0,0,2
cg12738979,0,0,0,2
cg23501567,0,0,0,1
cg14539442,0,1,1,1
cg04471454,0,0,0,2
cg04012618,0,0,0,2
cg03738352,0,0,0,2
cg06510397,0,0,0,2
cg03809954,0,0,0,1
cg02028389,0,0,0,2
cg09308829,0,0,0,2
cg03930532,0,0,0,2
cg09383860,0,0,0,1
cg08798933,0,0,0,2
cg04969688,0,0,0,1
cg07311521,0,0,0,2
cg21586215,0,0,0,2
cg18356159,0,0,0,2
cg04497154,0,0,0,1
cg08146865,0,0,0,2
cg18589016,0,0,0,2
cg05397886,0,0,0,1
cg13679048,0,0,0,2
cg21946299,0,0,0,2
cg19788741,0,0,0,2
cg04323979,0,0,0,1
cg13580857,0,0,0,2
cg08016802,0,0,0,2
cg18319687,0,0,0,1
cg00257542,0,0,0,1
cg26512993,0,0,0,1
cg02117859,0,0,0,1
cg21622555,0,0,0,2
cg00540941,0,0,0,1
cg24332767,0,0,0,2
cg02052774,0,0,0,2
cg15627380,0,0,0,1
cg22562590,0,0,0,1
cg00871979,0,0,0,1
cg04012364,0,0,0,2
cg15952045,0,0,0,1
cg13576200,0,0,0,1
cg22264014,0,0,0,2
cg26673648,0,0,0,1
cg01381130,0,0,0,1
cg22294804,0,0,0,2
cg01727686,0,0,0,1
cg21932368,0,0,0,2
cg06536629,0,0,0,2
cg10915772,0,0,0,1
cg18449721,0,0,0,2
cg19697530,0,0,0,2
cg19253643,0,0,0,1
cg26635603,0,0,0,1
cg00517407,0,0,0,2
cg21291641,0,0,0,2
cg13914598,0,0,0,2
cg05516842,0,0,0,1
cg03187614,0,0,0,1
cg05272099,0,0,0,2
cg10661615,0,0,0,2
cg05601623,0,0,0,2
cg13118545,0,0,0,2
cg12690313,0,0,0,2
cg06369090,0,0,0,2
cg08743392,0,0,0,2
cg02276361,0,0,0,1
cg08915922,0,0,0,2
cg04169908,0,0,0,1
cg12440258,0,0,0,2
cg26986937,0,0,0,2
cg22606205,0,0,0,2
cg27168632,0,0,0,2
cg25609143,0,0,0,2
cg01273565,0,0,0,2
cg08506672,0,0,0,1
cg22675486,0,0,0,2
cg05063395,0,0,0,2
cg01405761,0,0,0,2
cg10373196,0,0,0,2
cg00761129,0,0,0,2
cg14946515,0,0,0,2
cg25841943,0,0,0,2
cg25004270,0,1,1,1
cg19190269,0,0,0,2
cg03064832,0,0,0,2
cg17199468,0,0,0,2
cg22387756,0,0,0,1
cg04257169,0,0,0,2
cg09763325,0,0,0,2
cg12034118,0,0,0,2
cg13159559,0,0,0,2
cg17353057,0,0,0,2
cg00140191,0,0,1,1
cg06390079,0,0,0,2
cg01201782,0,0,0,2
cg09457801,0,0,0,2
cg06516800,0,0,0,1
cg24938727,0,0,0,2
cg05198733,0,0,0,1
cg01897756,0,0,0,2
cg01212071,0,0,0,2
cg25284762,0,0,0,1
cg21024422,0,0,0,1
cg06553513,0,0,0,2
cg10976318,0,0,0,2
cg13742526,0,0,0,2
cg08005992,0,0,0,2
cg11807492,0,0,0,2
cg25190513,0,0,0,1
cg14416559,0,0,0,2
cg02086801,0,0,0,2
cg02525995,0,0,0,1
cg24018756,0,0,0,1
cg27056129,0,0,0,2
cg18753594,0,0,0,2
cg01159380,0,0,1,1
cg23620822,0,0,0,2
cg01163842,0,0,0,2
cg22947959,0,0,0,1
cg18396811,0,0,0,2
cg26470101,0,0,0,1
cg00570697,0,0,0,2
cg23727043,0,0,1,2
cg07330196,0,0,0,1
cg05784562,0,0,0,1
cg08715988,0,0,0,1
cg05979118,0,0,0,2
cg12148940,0,0,0,1
cg08579962,0,0,0,1
cg04845171,0,0,0,1
cg03149432,0,0,0,1
cg20440575,0,0,0,2
cg13657659,0,0,0,2
cg04849201,0,0,0,1
cg19147912,0,0,0,1
cg12728517,0,0,0,2
cg03447530,0,0,0,1
cg21184800,0,0,0,2
cg11362449,0,0,0,1
cg12311636,0,0,0,1
cg06437740,0,0,0,1
cg03999216,0,0,0,2
cg17477493,0,0,0,1
cg22259778,0,0,0,1
cg10120572,0,0,0,1
cg07797660,0,0,0,2
cg08677954,0,0,0,2
cg06635552,0,0,0,2
cg09899094,0,0,0,2
cg13845147,0,0,0,2
cg23037132,0,0,0,2
cg15262505,0,0,0,2
cg00056489,0,0,0,2
cg09759737,0,0,0,1
cg12188268,0,0,0,2
cg24011500,0,0,0,1
cg15002713,0,0,0,1
cg13817545,0,0,0,2
cg03553786,0,0,0,2
cg06218627,0,0,0,2
cg17298884,0,0,0,1
cg18231614,0,0,0,2
cg14835981,0,0,0,1
cg08418980,0,0,0,2
cg14007549,0,0,0,2
cg08317133,0,1,1,1
cg26741350,0,0,1,1
cg01682784,0,0,0,2
cg17279652,0,0,0,1
cg05128414,0,0,0,1
cg04132146,0,0,0,2
cg23970331,0,0,0,1
cg15521264,0,0,0,2
cg07291005,0,0,0,2
cg27194152,0,0,0,1
cg10403934,0,0,0,1
cg10922264,0,0,0,1
cg22583444,0,0,0,1
cg18507707,0,0,0,2
cg02761568,0,0,0,2
cg05495029,0,0,0,2
cg08645889,0,0,1,2
cg00945293,0,0,0,2
cg25501930,0,0,0,1
cg10090836,0,0,0,1
cg15189070,0,0,0,1
cg10497884,0,0,0,2
cg26345216,0,0,0,1
cg09566131,0,0,0,2
cg09561280,0,0,0,2
cg11296715,0,0,0,2
cg26659805,0,0,0,2
cg01449168,0,0,0,2
cg00896540,0,0,0,2
cg21963854,0,0,0,2
cg16240137,0,0,0,1
cg23050300,0,0,0,2
cg08471800,0,0,0,2
cg07905273,0,0,0,2
cg24277586,0,0,0,1
cg03871549,0,0,0,2
cg00123181,0,0,0,2
cg06549530,0,0,0,2
cg02535735,0,0,0,1
cg04327529,0,0,0,2
cg17639046,0,0,0,2
cg01082601,0,0,0,2
cg19042136,0,0,0,2
cg10846615,0,0,1,1
cg17179051,0,0,0,1
cg05184917,0,0,0,2
cg27271756,0,0,0,2
cg07823913,0,0,0,1
cg01040169,0,0,0,1
cg09441152,0,0,0,2
cg23623107,0,0,0,1
cg16622863,0,0,0,2
cg22358236,0,0,0,2
cg08153404,0,0,0,2
cg19317333,0,0,0,2
cg20548032,0,0,0,1
cg13824156,0,0,0,1
cg06237092,0,0,0,2
cg19090522,0,0,0,1
cg06679538,0,0,0,2
cg21834739,0,0,0,2
cg18626098,0,0,0,2
cg13717425,0,0,0,2
cg12876900,0,0,0,1
cg16050974,0,0,0,2
cg19499998,0,0,1,1
cg00877056,0,0,0,1
cg10607485,0,0,0,2
cg18275316,0,0,1,1
cg24040576,0,0,0,1
cg19238531,0,0,0,2
cg07202110,0,0,0,1
cg08276984,0,0,0,2
cg26281453,0,0,0,2
cg14354327,0,0,0,1
cg25397973,0,0,0,2
cg09449449,0,0,0,2
cg06023349,0,0,0,2
cg19968946,0,0,0,2
cg10962407,0,0,0,1
cg24044238,0,0,0,2
cg19987142,0,0,0,2
cg25575845,0,0,0,1
cg05121812,0,0,0,2
cg12671565,0,0,0,2
cg01802295,0,0,0,2
cg11372696,0,0,0,1
cg14371636,0,0,0,2
cg00500498,0,0,0,2
cg11278260,0,0,0,2
cg07468260,0,0,0,2
cg13536051,0,0,1,1
cg13353683,0,0,0,2
cg13873762,0,0,0,2
cg18537571,0,0,0,2
cg07429394,0,0,0,2
ch.X.703923F,0,0,0,1
cg16562486,0,0,0,2
cg26932226,0,0,0,2
cg02250708,0,0,0,1
cg22354618,0,0,0,2
cg19671246,0,0,0,2
cg11442717,0,0,0,1
cg04941630,0,0,0,2
cg19995539,0,0,0,1
cg24341220,0,0,0,2
cg05670459,0,0,0,2
cg17706896,0,0,0,2
cg19855618,0,0,0,2
cg10778240,0,0,0,2
cg20078119,0,0,0,2
cg26879788,0,0,0,1
cg20776947,0,0,0,2
cg26377880,0,0,0,2
cg07791065,0,0,0,2
cg23086176,0,0,0,1
cg04864083,0,0,0,2
cg23719318,0,0,0,2
cg27403098,0,0,0,2
cg03720043,0,0,0,2
cg16256065,0,0,0,1
cg16837557,0,0,0,2
cg17662493,0,0,1,1
cg11505338,0,0,0,1
cg04878644,0,0,0,2
cg18710784,0,0,0,1
cg17152214,0,0,0,1
cg10865856,0,0,0,1
cg03868159,0,0,0,2
cg15439078,0,0,1,1
cg24223558,0,0,0,1
cg14480858,0,0,0,2
cg09644356,0,0,0,1
cg04100684,0,0,0,2
cg04760708,0,0,0,2
cg27373972,0,0,0,1
cg25181749,0,0,0,1
cg10251973,0,0,0,2
cg20172500,0,0,0,1
cg25883405,0,0,0,2
cg06932776,0,0,0,2
cg11188679,0,0,0,2
cg23328050,0,0,0,2
cg16107322,0,0,0,2
cg04552470,0,0,0,2
cg08393356,0,0,0,1
cg01284869,0,0,0,2
cg07896108,0,0,0,1
cg22571393,0,0,1,1
cg18988170,0,0,0,2
cg16592453,0,0,0,1
cg06211255,0,0,0,2
cg22426938,0,0,0,2
cg03944089,0,0,0,2
cg09595479,0,0,0,2
cg26258845,0,0,0,1
cg09892203,0,0,0,1
cg00221327,0,0,0,1
cg27504292,0,0,0,2
cg19267760,0,0,0,1
cg26864395,0,0,0,2
cg12856183,0,0,0,2
cg07829465,0,0,0,1
cg15215830,0,0,0,2
cg14318942,0,0,0,2
cg11229715,0,0,0,2
cg11691189,0,0,0,1
cg12991830,0,0,0,2
cg22699052,0,0,1,1
cg09485472,0,0,0,1
cg14752227,0,0,1,1
cg04787343,0,0,0,2
cg11746846,0,0,0,1
cg17852021,0,0,0,2
cg15120477,0,0,0,1
cg24572400,0,0,0,2
cg00117869,0,0,0,1
cg01216607,0,0,0,2
cg17222164,0,0,0,2
cg01204964,0,0,1,1
cg07955004,1,1,1,1
cg04371440,0,0,0,2
cg15035364,0,0,0,2
cg19710662,0,0,0,1
cg16595365,0,0,0,2
cg03370106,0,0,0,1
cg18571419,0,0,0,2
cg20624137,0,0,0,1
cg15412736,0,0,0,2
cg00889769,0,0,0,2
cg14649140,0,0,0,2
cg25531618,0,0,0,1
cg07594031,0,0,0,2
cg05816239,0,0,0,2
cg00295604,0,0,0,2
cg04941721,0,0,0,2
cg11613164,0,0,0,2
cg02387679,0,0,0,2
cg22134372,0,0,0,2
cg27099166,0,0,0,2
cg09735674,0,0,0,1
cg23173517,0,0,0,2
cg20713333,0,0,0,1
cg01520402,0,0,0,1
cg00328593,0,0,0,2
cg17348479,0,0,0,1
cg26643142,0,0,0,2
cg14575053,0,0,0,2
cg05092885,0,0,0,1
cg08620751,0,0,0,1
cg21562321,0,0,0,1
cg22374901,0,0,0,2
cg27613976,0,0,0,2
cg06127885,0,0,1,1
cg14840664,0,0,0,1
cg25045242,0,0,0,1
cg12747844,0,0,0,1
cg14534464,0,0,0,2
cg21508023,0,0,0,2
cg13417559,0,0,0,2
cg14461650,0,0,0,1
cg03885264,0,0,0,2
cg02868338,0,0,0,2
cg08846467,0,0,0,2
cg27565938,0,0,0,1
cg08904363,0,0,0,2
cg12253071,0,0,0,1
cg06259664,0,1,1,1
cg18453904,0,0,0,2
cg19144392,0,0,0,1
cg16189596,0,0,0,2
And I want to create a seaborn heatmap like this:
plt.figure(figsize=(470, 60))
sns.set(font_scale = 14)
df=comparison.T
# create a Boolean mask of df
mask = df.ge(1).all()
# use the mask to update a list of labels
cols = [col if m else '' for (col, m) in zip(df.columns, mask)]
# plot with custom labels
ax = sns.heatmap(df, xticklabels=cols,cmap="crest_r")
ax.set_xticklabels(labels=cols, fontsize=200)
plt.show()
However, sometimes due to the narrow space the xtick labels overlap. Is there any way to add more spacing while still providing a readable image (not too small so that it cannot be read) or to put them one below the other?

Surface triangulation and interpolation in python 3

I have 3 lists of equal length of x, y and z coordinates.
With them, I need to triangulate a surface, and retrieve values that lie in a line over that surface. In other words, I need the values that lie on that surface that intersect a given plane.
Problem is, I have no idea where to start.
I have tried scipy interp2d, but it seems I need more z values them what I actually have (like shown in this answer: Python interpolation and extracting value of z for x and y?.
# this is the data I have
x = [0.0, 17.67599999997765, 49.08499999996275, 90.57299999985844, 136.60500000044703]
y = [0.0, 45.22349889159747, 66.50303846438841, 114.04427618243405, 187.7707039612985]
z = [0.0, 1.8700000000000045, 1.9539999999999509, 1.3929999999999154, 1.6299999999999955]
I need a final grid with x y z values that look something like this:
I don't really need too much resolution
My desired final result is to be able to retrieve specific values on top of that surface
Like the point line in this image:
I have also tried looking at geospatial libraries, but I couldn't find a solution either.
Maybe it's possible to interpolate the z values that I need? But I'm not really sure how to do this. I have never used scipy library before, and I'm still struggling to understand it.
I'm using python 3.9
You barely have any data, so if you don't choose your intersecting plane carefully, you'll get no results back (or nonsense back). This includes the case of x=y; you can't do that at all - so the graph you've shown is entirely inapplicable to your data.
import numpy as np
import scipy.interpolate
x = [0.0, 17.6759999999776500, 49.0849999999627500, 90.5729999998584400, 136.6050000004470300]
y = [0.0, 45.2234988915974700, 66.5030384643884100, 114.0442761824340500, 187.7707039612985000]
z = [0.0, 1.8700000000000045, 1.9539999999999509, 1.3929999999999154, 1.6299999999999955]
xyi = np.empty((200, 2))
xyi[:, 0] = np.arange(200)
xyi[:, 1] = xyi[:, 0] * 1.374
zi = scipy.interpolate.griddata(
points=(x, y), values=z,
xi=xyi,
method='cubic',
)
good_vals = ~np.isnan(zi)
xyz = np.empty((np.count_nonzero(good_vals), 3))
xyz[:, :2] = xyi[good_vals, :]
xyz[:, 2] = zi[good_vals]
print(xyz)
[[0.00000000e+00 0.00000000e+00 0.00000000e+00]
[1.00000000e+00 1.37400000e+00 4.68988354e-02]
[2.00000000e+00 2.74800000e+00 9.44855957e-02]
[3.00000000e+00 4.12200000e+00 1.42698116e-01]
[4.00000000e+00 5.49600000e+00 1.91474231e-01]
[5.00000000e+00 6.87000000e+00 2.40751776e-01]
[6.00000000e+00 8.24400000e+00 2.90468585e-01]
[7.00000000e+00 9.61800000e+00 3.40562494e-01]
[8.00000000e+00 1.09920000e+01 3.90971337e-01]
[9.00000000e+00 1.23660000e+01 4.41632950e-01]
[1.00000000e+01 1.37400000e+01 4.92485168e-01]
[1.10000000e+01 1.51140000e+01 5.43465824e-01]
[1.20000000e+01 1.64880000e+01 5.94512755e-01]
[1.30000000e+01 1.78620000e+01 6.45563795e-01]
[1.40000000e+01 1.92360000e+01 6.96556779e-01]
[1.50000000e+01 2.06100000e+01 7.47429542e-01]
[1.60000000e+01 2.19840000e+01 7.98119919e-01]
[1.70000000e+01 2.33580000e+01 8.48565744e-01]
[1.80000000e+01 2.47320000e+01 8.98704854e-01]
[1.90000000e+01 2.61060000e+01 9.48475082e-01]
[2.00000000e+01 2.74800000e+01 9.97814263e-01]
[2.10000000e+01 2.88540000e+01 1.04666023e+00]
[2.20000000e+01 3.02280000e+01 1.09495083e+00]
[2.30000000e+01 3.16020000e+01 1.14262388e+00]
[2.40000000e+01 3.29760000e+01 1.18961722e+00]
[2.50000000e+01 3.43500000e+01 1.23586870e+00]
[2.60000000e+01 3.57240000e+01 1.28131613e+00]
[2.70000000e+01 3.70980000e+01 1.32589737e+00]
[2.80000000e+01 3.84720000e+01 1.36955024e+00]
[2.90000000e+01 3.98460000e+01 1.41221257e+00]
[3.00000000e+01 4.12200000e+01 1.45382221e+00]
[3.10000000e+01 4.25940000e+01 1.49431699e+00]
[3.20000000e+01 4.39680000e+01 1.53363474e+00]
[3.30000000e+01 4.53420000e+01 1.57171329e+00]
[3.40000000e+01 4.67160000e+01 1.60849049e+00]
[3.50000000e+01 4.80900000e+01 1.64390417e+00]
[3.60000000e+01 4.94640000e+01 1.67789216e+00]
[3.70000000e+01 5.08380000e+01 1.71039230e+00]
[3.80000000e+01 5.22120000e+01 1.74134241e+00]
[3.90000000e+01 5.35860000e+01 1.77068035e+00]
[4.00000000e+01 5.49600000e+01 1.79834394e+00]
[4.10000000e+01 5.63340000e+01 1.82427101e+00]
[4.20000000e+01 5.77080000e+01 1.84839941e+00]
[4.30000000e+01 5.90820000e+01 1.87066696e+00]
[4.40000000e+01 6.04560000e+01 1.89101151e+00]
[4.50000000e+01 6.18300000e+01 1.90937088e+00]
[4.60000000e+01 6.32040000e+01 1.92570604e+00]
[4.70000000e+01 6.45780000e+01 1.94056076e+00]
[4.80000000e+01 6.59520000e+01 1.95421968e+00]
[4.90000000e+01 6.73260000e+01 1.96719695e+00]
[5.00000000e+01 6.87000000e+01 1.97928362e+00]
[5.10000000e+01 7.00740000e+01 1.98942207e+00]
[5.20000000e+01 7.14480000e+01 1.99700320e+00]
[5.30000000e+01 7.28220000e+01 2.00180807e+00]
[5.40000000e+01 7.41960000e+01 2.00361776e+00]
[5.50000000e+01 7.55700000e+01 2.00221333e+00]
[5.60000000e+01 7.69440000e+01 1.99737586e+00]
[5.70000000e+01 7.83180000e+01 1.98888640e+00]
[5.80000000e+01 7.96920000e+01 1.97652604e+00]
[5.90000000e+01 8.10660000e+01 1.96007583e+00]
[6.00000000e+01 8.24400000e+01 1.93931685e+00]
[6.10000000e+01 8.38140000e+01 1.91403017e+00]
[6.20000000e+01 8.51880000e+01 1.88497097e+00]
[6.30000000e+01 8.65620000e+01 1.85740456e+00]
[6.40000000e+01 8.79360000e+01 1.83466390e+00]
[6.50000000e+01 8.93100000e+01 1.81970145e+00]
[6.60000000e+01 9.06840000e+01 1.81546971e+00]
[6.70000000e+01 9.20580000e+01 1.82177337e+00]
[6.80000000e+01 9.34320000e+01 1.82842946e+00]
[6.90000000e+01 9.48060000e+01 1.83439551e+00]
[7.00000000e+01 9.61800000e+01 1.83969621e+00]
[7.10000000e+01 9.75540000e+01 1.84435625e+00]
[7.20000000e+01 9.89280000e+01 1.84840034e+00]
[7.30000000e+01 1.00302000e+02 1.85185316e+00]
[7.40000000e+01 1.01676000e+02 1.85473940e+00]
[7.50000000e+01 1.03050000e+02 1.85708377e+00]
[7.60000000e+01 1.04424000e+02 1.85891096e+00]
[7.70000000e+01 1.05798000e+02 1.86024566e+00]
[7.80000000e+01 1.07172000e+02 1.86111256e+00]
[7.90000000e+01 1.08546000e+02 1.86153636e+00]
[8.00000000e+01 1.09920000e+02 1.86154176e+00]
[8.10000000e+01 1.11294000e+02 1.86115344e+00]
[8.20000000e+01 1.12668000e+02 1.86039610e+00]
[8.30000000e+01 1.14042000e+02 1.85929444e+00]
[8.40000000e+01 1.15416000e+02 1.85787402e+00]
[8.50000000e+01 1.16790000e+02 1.85624017e+00]
[8.60000000e+01 1.18164000e+02 1.85445481e+00]
[8.70000000e+01 1.19538000e+02 1.85252055e+00]
[8.80000000e+01 1.20912000e+02 1.85043999e+00]
[8.90000000e+01 1.22286000e+02 1.84821574e+00]
[9.00000000e+01 1.23660000e+02 1.84585039e+00]
[9.10000000e+01 1.25034000e+02 1.84334656e+00]
[9.20000000e+01 1.26408000e+02 1.84070685e+00]
[9.30000000e+01 1.27782000e+02 1.83793385e+00]
[9.40000000e+01 1.29156000e+02 1.83503019e+00]
[9.50000000e+01 1.30530000e+02 1.83199845e+00]
[9.60000000e+01 1.31904000e+02 1.82884125e+00]
[9.70000000e+01 1.33278000e+02 1.82556119e+00]
[9.80000000e+01 1.34652000e+02 1.82216087e+00]
[9.90000000e+01 1.36026000e+02 1.81864290e+00]
[1.00000000e+02 1.37400000e+02 1.81500988e+00]
[1.01000000e+02 1.38774000e+02 1.81126441e+00]
[1.02000000e+02 1.40148000e+02 1.80740911e+00]
[1.03000000e+02 1.41522000e+02 1.80344657e+00]
[1.04000000e+02 1.42896000e+02 1.79937940e+00]
[1.05000000e+02 1.44270000e+02 1.79521020e+00]
[1.06000000e+02 1.45644000e+02 1.79094157e+00]
[1.07000000e+02 1.47018000e+02 1.78657613e+00]
[1.08000000e+02 1.48392000e+02 1.78211648e+00]
[1.09000000e+02 1.49766000e+02 1.77756521e+00]
[1.10000000e+02 1.51140000e+02 1.77292494e+00]
[1.11000000e+02 1.52514000e+02 1.76819827e+00]
[1.12000000e+02 1.53888000e+02 1.76338780e+00]
[1.13000000e+02 1.55262000e+02 1.75849613e+00]
[1.14000000e+02 1.56636000e+02 1.75352588e+00]
[1.15000000e+02 1.58010000e+02 1.74847964e+00]
[1.16000000e+02 1.59384000e+02 1.74336002e+00]
[1.17000000e+02 1.60758000e+02 1.73816962e+00]
[1.18000000e+02 1.62132000e+02 1.73291105e+00]
[1.19000000e+02 1.63506000e+02 1.72758692e+00]
[1.20000000e+02 1.64880000e+02 1.72219982e+00]
[1.21000000e+02 1.66254000e+02 1.71675236e+00]
[1.22000000e+02 1.67628000e+02 1.71124714e+00]
[1.23000000e+02 1.69002000e+02 1.70568677e+00]
[1.24000000e+02 1.70376000e+02 1.70007386e+00]
[1.25000000e+02 1.71750000e+02 1.69441100e+00]
[1.26000000e+02 1.73124000e+02 1.68870081e+00]
[1.27000000e+02 1.74498000e+02 1.68294588e+00]
[1.28000000e+02 1.75872000e+02 1.67714882e+00]
[1.29000000e+02 1.77246000e+02 1.67131224e+00]
[1.30000000e+02 1.78620000e+02 1.66543873e+00]
[1.31000000e+02 1.79994000e+02 1.65953091e+00]
[1.32000000e+02 1.81368000e+02 1.65359138e+00]
[1.33000000e+02 1.82742000e+02 1.64762273e+00]
[1.34000000e+02 1.84116000e+02 1.64162758e+00]
[1.35000000e+02 1.85490000e+02 1.63560853e+00]
[1.36000000e+02 1.86864000e+02 1.62956819e+00]]

How to find the shortest distance between two line segments capturing the sign values with python

I have a pandas dataframe of the form:
benchmark_x benchmark_y ref_point_x ref_point_y
0 525039.140 175445.518 525039.145 175445.539
1 525039.022 175445.542 525039.032 175445.568
2 525038.944 175445.558 525038.954 175445.588
3 525038.855 175445.576 525038.859 175445.576
4 525038.797 175445.587 525038.794 175445.559
5 525038.689 175445.609 525038.679 175445.551
6 525038.551 175445.637 525038.544 175445.577
7 525038.473 175445.653 525038.459 175445.594
8 525038.385 175445.670 525038.374 175445.610
9 525038.306 175445.686 525038.289 175445.626
I am trying to find the shortest distance from the line to the benchmark such that if the line is above the benchmark the distance is positive and if it is below the benchmark the distance is negative. See image below:
I used the KDTree from scipy like so:
from scipy.spatial import KDTree
tree=KDTree(df[["benchmark_x", "benchmark_y"]])
test = df.apply(lambda row: tree.query(row[["ref_point_x", "ref_point_y"]]), axis=1)
test=test.apply(pd.Series, index=["distance", "index"])
This seems to work except that it fails to capture the negative values as a result that the line is below the benchmark.
# recreating your example
columns = "benchmark_x benchmark_y ref_point_x ref_point_y".split(" ")
data = """525039.140 175445.518 525039.145 175445.539
525039.022 175445.542 525039.032 175445.568
525038.944 175445.558 525038.954 175445.588
525038.855 175445.576 525038.859 175445.576
525038.797 175445.587 525038.794 175445.559
525038.689 175445.609 525038.679 175445.551
525038.551 175445.637 525038.544 175445.577
525038.473 175445.653 525038.459 175445.594
525038.385 175445.670 525038.374 175445.610
525038.306 175445.686 525038.289 175445.626"""
data = [float(x) for x in data.replace("\n"," ").split(" ") if len(x)>0]
arr = np.array(data).reshape(-1,4)
df = pd.DataFrame(arr, columns=columns)
# adding your two new columns to the df
from scipy.spatial import KDTree
tree=KDTree(df[["benchmark_x", "benchmark_y"]])
df["distance"], df["index"] = tree.query(df[["ref_point_x", "ref_point_y"]])
Now to compare if one line is above the other or not, we have to evaluate y at the same x position. Therefore we need to interpolate the y points for the x positions of the other line.
df = df.sort_values("ref_point_x") # sorting is required for interpolation
xy_refpoint = df[["ref_point_x", "ref_point_y"]].values
df["ref_point_y_at_benchmark_x"] = np.interp(df["benchmark_x"], xy_refpoint[:,0], xy_refpoint[:,1])
And finally your criterium can be evaluated and applied:
df["distance"] = np.where(df["ref_point_y_at_benchmark_x"] < df["benchmark_y"], -df["distance"], df["distance"])
# or change the < to <,>,<=,>= as you wish

pyntcloud to polyhedral from pointcloud with normals

I have a pointcloud which I imported to the pyntcloud libray as a series of points, it is a fully 3D pointcloud, as in it bounds forms a volume.
points = pd.DataFrame(points)
points.columns = ['x', 'y', 'z']
cloud = PyntCloud(points)
I calculate the normals
k_neighbors = cloud.get_neighbors(k=10)
cloud_norm=cloud
cloud_norm.add_scalar_field("normals", k_neighbors=k_neighbors)
I would like to generate a solid object, preferably a polyhedral, I've looked at the CGAL bindings and pymesh but I'm not finding a working solution. Any ideas?
The data is structured like this
cloud.points
x y z nx(11) ny(11) nz(11)
0 991.538025 267.574707 191.911194 -0.065332 -0.106776 0.992134
1 991.545227 267.598602 191.912704 -0.157886 0.069813 0.984986
2 991.546570 267.587189 191.913498 -0.124825 -0.085891 0.988454
3 991.548889 267.565887 191.910797 -0.082405 -0.210254 0.974168
4 991.549805 267.563507 191.911499 -0.094382 -0.256764 0.961855
5 991.552124 267.624298 191.910599 -0.192515 0.238861 0.951779
CloudCompare has a plugin that can do this. It uses an open source plugin that does "Poisson reconstruction", see https://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version12.00/
It Generates .ply files.

plotting 3D bar graph in matlab or excel

I need to plot a 3D bar graph in matlab or excel. I am going to use some dates in x-axis, time in y-axis and some amount on the z-axis. Each record in csv file looks like ...
18-Apr, 21, 139.45
I am not sure how to do this right. can anyone help me please. I tried using pivort chart of excel. however, i could not manipulate the axis and use appropriate space between each tick.
thanks
kaisar
Since the question is lacking details, let me illustrate with an example.
Consider the following code:
%# read file contents: date,time,value
fid = fopen('data.csv','rt');
C = textscan(fid, '%s %s %f', 'Delimiter',',');
fclose(fid);
%# correctly reshape the data, and extract x/y labels
num = 5;
d = reshape(C{1},num,[]); d = d(1,:);
t = reshape(C{2},num,[]); t = t(:,1);
Z = reshape(C{3},num,[]);
%# plot 3D bars
bar3(Z)
xlabel('date'), ylabel('time'), zlabel('value')
set(gca, 'XTickLabel',d, 'YTickLabel',t)
I ran on the following data file:
data.csv
18-Apr,00:00,0.85535
18-Apr,03:00,0.38287
18-Apr,06:00,0.084649
18-Apr,09:00,0.73387
18-Apr,12:00,0.33199
19-Apr,00:00,0.83975
19-Apr,03:00,0.37172
19-Apr,06:00,0.82822
19-Apr,09:00,0.17652
19-Apr,12:00,0.12952
20-Apr,00:00,0.87988
20-Apr,03:00,0.044079
20-Apr,06:00,0.68672
20-Apr,09:00,0.73377
20-Apr,12:00,0.43717
21-Apr,00:00,0.37984
21-Apr,03:00,0.97966
21-Apr,06:00,0.39899
21-Apr,09:00,0.44019
21-Apr,12:00,0.15681
22-Apr,00:00,0.32603
22-Apr,03:00,0.31406
22-Apr,06:00,0.8945
22-Apr,09:00,0.24702
22-Apr,12:00,0.31068
23-Apr,00:00,0.40887
23-Apr,03:00,0.70801
23-Apr,06:00,0.14364
23-Apr,09:00,0.87132
23-Apr,12:00,0.083156
24-Apr,00:00,0.46174
24-Apr,03:00,0.030389
24-Apr,06:00,0.7532
24-Apr,09:00,0.70004
24-Apr,12:00,0.21451
25-Apr,00:00,0.6799
25-Apr,03:00,0.55729
25-Apr,06:00,0.85068
25-Apr,09:00,0.55857
25-Apr,12:00,0.90177
26-Apr,00:00,0.41952
26-Apr,03:00,0.35813
26-Apr,06:00,0.48899
26-Apr,09:00,0.25596
26-Apr,12:00,0.92917
27-Apr,00:00,0.46676
27-Apr,03:00,0.25401
27-Apr,06:00,0.43122
27-Apr,09:00,0.70253
27-Apr,12:00,0.40233
Use MATLAB's CSV reading functions (or write your own) and then use bar3 to display the data.

Resources