Skip to content

Instantly share code, notes, and snippets.

@ivder
Created February 19, 2019 03:45
Show Gist options
  • Save ivder/6e39ff6363802b163b14219ff3fe027a to your computer and use it in GitHub Desktop.
Save ivder/6e39ff6363802b163b14219ff3fe027a to your computer and use it in GitHub Desktop.
Convert longitude and latitude coordinate that extracted from Google Earth KML format to txt format
# -*- coding: utf-8 -*-
text = "127.1245143092074,37.48605020263803,0 127.1227918767437,37.48604832058984,0 127.1243979114171,37.48275282702311,0 127.1272652345932,37.47650564339881,0 127.1269005294987,37.47562108198129,0 127.1264902143204,37.47470615899766,0 127.1261222584311,37.47437246324513,0 127.126157672444,37.47371699021247,0 127.1257493554023,37.47291716136547,0 127.1254389085777,37.47213888086183,0 127.125117506637,37.47062544236839,0 127.1251423798022,37.46920765516041,0 127.1252461714744,37.46822418442232,0 127.1256680519576,37.46484452642618,0 127.1254663648703,37.46252995708048,0 127.1253955340772,37.45829374652769,0 127.1258727729014,37.45441627283644,0 127.1260535025414,37.44991980413442,0 127.1249501399596,37.44592241319028,0 127.1241308101934,37.44408589006341,0 127.123498216068,37.44253029858053,0 127.1229866609585,37.44132886161613,0 127.122682481901,37.43719912651704,0 127.1230781217638,37.43530852646552,0 127.1230777605002,37.43392112083875,0 127.1234248877856,37.43258926522761,0 127.1233652654513,37.42754536412633,0 127.1230384579145,37.42329218723156,0 127.1232227471902,37.42035128454372,0 127.1223339865287,37.41657448877928,0 127.1210927171772,37.41458355196294,0 127.1192440454664,37.41233008491515,0 127.1175182136866,37.41049794800899,0 127.1155842097515,37.40892956497538,0 127.1132110390278,37.40800616405455,0 127.1102578263263,37.40760125156436,0 127.1079834736168,37.40759788709327,0 127.104638360847,37.40759379450169,0 127.101052301582,37.40752474239559,0 127.0998716510847,37.40730826471926,0 127.0982252009742,37.40685540880221,0 127.097080255103,37.40658293658674,0 127.0966049066479,37.40687256155868,0 127.0951671294765,37.40710490071984,0 127.0942553168737,37.40704483645357,0 127.0933186216926,37.4066740102166,0 127.0929300697669,37.40570459870296,0 127.0928053996077,37.40487628972648,0 127.0930857963091,37.40414307036773,0 127.0936358095198,37.40368862089108,0 127.0945563639889,37.40351692906034,0 127.0955330668102,37.40346671017512,0 127.0965794302002,37.40321121957263,0 127.0969540742064,37.40302480814425,0 127.0979320609723,37.40222533464846,0 127.0992174801062,37.40059107167792,0 127.0993296517573,37.39912509802849,0 127.0993352504762,37.39767509765832,0 127.0998543368786,37.39682624531348,0 127.1004329209394,37.39583072590707,0 127.1009148320465,37.39480431229477,0 127.1016587430956,37.39107698456822,0 127.1023765438159,37.3875108372625,0 127.1030396748075,37.38322404433114,0 127.1030743210734,37.37770800469634,0 127.1030463513001,37.37264951965103,0 127.1030555030047,37.36859182079719,0 127.1030000211343,37.36362730950596,0 127.1031738083308,37.35832915433705,0 127.1034246904404,37.35271257380212,0 127.1034367281106,37.34736179929951,0 127.1034483388738,37.34220005927906,0 127.1034219414142,37.33600598647534,0 127.1034339660867,37.33065987366118,0 127.1034493085575,37.32383757169226,0 127.1034642385267,37.31719749935078,0 127.1034795461466,37.31038824203264,0 127.1034953040947,37.30337736972498,0 127.1035131210424,37.29544884308375,0 127.1030344428044,37.29315382892064,0 127.1027713223549,37.2926186972528,0 127.1020401107099,37.29216715390611,0 127.101522530261,37.29188845058028,0 127.1012169234789,37.29135831552982,0 127.1002927712222,37.29081941219668,0 127.0996960670178,37.2902912681517,0 127.0987261934848,37.29009899681189,0 127.0975446452443,37.28970250738656,0 127.0964146178179,37.28987168072059,0 127.094385665028,37.28997163654432,0 127.0892109299218,37.29082066767287,0 127.0837168005862,37.29234513041784,0 127.0744555677805,37.29423030578973,0 127.0628915997801,37.2962435124962,0 127.0545737824145,37.29792899850556,0 127.0482833427424,37.30084723834317,0 127.0372830116197,37.30735368771572,0 127.0281809211104,37.31277612489924,0 127.025798625192,37.31345979730922,0 127.0238190756267,37.3133253489426,0 127.0203618418865,37.31273771808903,0 127.016896115053,37.31170440577511,0 127.0133609079794,37.31082476060247,0 127.0094812085923,37.31065603945726,0 127.0048037669544,37.31190534691997,0 127.0023312830249,37.31334558871617,0 126.9950716584366,37.31694916822211,0 126.9863668873078,37.32001181234308,0 126.9784731380796,37.32029155838453,0 126.9708970251618,37.31999641736967,0 126.9610066908534,37.32360671909483,0 126.9514454063255,37.32765342969259,0 126.9425562945512,37.32850248371121,0 126.9412580513175,37.32870098254738,0 126.940581685122,37.32877802813851,0 126.9399906386063,37.32887777203258,0 126.939376794859,37.32895646600002,0 126.9383148757971,37.32896819453093,0 126.9374669496339,37.32915132653702,0 126.9368993529195,37.32946158072542,0 126.9365373144753,37.32991055322378,0 126.9353816563322,37.33004548894918,0 126.9345835297679,37.33011717350681,0 126.933759691284,37.33013142550353,0 126.9346544285881,37.32991349931687,0 126.9347411887885,37.32963486402874,0 126.9346784961136,37.32919614180078,0 126.9346711034707,37.32868961265092,0 126.9348182453201,37.32836627236279,0 126.9352490089025,37.32814174406399,0 126.9356161950139,37.3281225342203,0 126.9360819582399,37.32826660078124,0 126.9369308154016,37.32848365453487,0 126.9381545502271,37.3284452049724,0 126.9391238150956,37.32858835060064,0 126.9399520317668,37.32849919486162,0 126.9411705301941,37.32847465388684,0 126.9428104005678,37.3283681840618,0 126.9475653001567,37.32815603817788,0 126.9510880043825,37.32753316879135,0 126.9551504655356,37.32638565168615,0 126.9588651647835,37.32474479099996,0 126.9638937649264,37.32222770618155,0 126.9684991922071,37.32028041408121,0 126.9743592479358,37.31981401896443,0 126.9805756167508,37.32040968181011,0 126.9846438564204,37.32018958675948,0 126.9888546698963,37.31930909935868,0 126.9920415005635,37.31822315044003,0 126.9956924468575,37.31641413377519,0 127.0020276165282,37.31313670086696,0 127.0027311672932,37.31294574952362,0 127.0083782667818,37.31074680216045,0 127.0129375761106,37.31048554783718,0 127.0180933812666,37.31188583571966,0 127.0245727004873,37.31362944483906,0 127.0296249844523,37.31248558149741,0 127.034146923933,37.30986922988841,0 127.0434543727552,37.303941084749,0 127.048375549491,37.30039309787962,0 127.0495197516952,37.29897609130047,0 127.0492536543879,37.29835553250917,0 127.0487250394697,37.29823535660467,0 127.0479964815739,37.29804518877637,0 127.0473345127356,37.29785270225323,0 127.046593084062,37.29757804642385,0 127.0459731030894,37.29733561926273,0 127.0453101145774,37.2967023193169,0 127.044738992363,37.29634777168372,0 127.0442252769359,37.29601287569787,0 127.0437010449564,37.29569001212172,0 127.0428946861084,37.29547231902391,0 127.0425477589264,37.29573646905502,0 127.0428370208403,37.29606071856394,0 127.0433177843019,37.29610614794031,0 127.0452510671137,37.29574184134478,0 127.0466971045489,37.29550962568435,0 127.0477445414757,37.29531769086822,0 127.0487920674704,37.29528498102437,0 127.0483811655034,37.29554872573856,0 127.0473024446298,37.29560650092987,0 127.0461057617144,37.29584184057011,0 127.0455995202365,37.29604081434759,0 127.0454950821839,37.29669587503255,0 127.0461154127226,37.29690313138011,0 127.0472997462383,37.29713740286986,0 127.0478504298988,37.29749380135677,0 127.0484885283284,37.29777228411341,0 127.0496707942932,37.29835367529376,0 127.0511915339512,37.29863415248208,0 127.0526000030349,37.29839921851423,0 127.0597957627886,37.29668817547368,0 127.0649643342479,37.29566267452332,0 127.0689779951762,37.29499736641826,0 127.0755062938464,37.29385190103888,0 127.0814643344943,37.29294185219061,0 127.0925849774708,37.28997918603321,0 127.0984898804479,37.28961107321114,0 127.1001518141251,37.2897843248798,0 127.104479779025,37.28998358487625,0 127.1055414645217,37.28994099481558,0 127.105996704961,37.2898171725836,0 127.1061729707367,37.28950178744099,0 127.1061626112442,37.28914561925076,0 127.1060119470684,37.28892526864631,0 127.1055621859018,37.28878097084242,0 127.1055257884824,37.28876996987558,0 127.1050684114586,37.28879664240182,0 127.1047843946563,37.28905249090047,0 127.1046172116885,37.28957724399901,0 127.1046797658224,37.28977815986688,0 127.1047825234238,37.29045598695021,0 127.1045821449229,37.29105223781254,0 127.1043499121262,37.29165855267178,0 127.1041468671463,37.29220908613631,0 127.1039295509692,37.29406254275951,0 127.1038662165532,37.2964003968546,0 127.1038716790504,37.29958548053817,0 127.1038555886553,37.30298680705422,0 127.1038043822363,37.30851928711337,0 127.103791437042,37.31440727964662,0 127.1037815148609,37.31891965749369,0 127.1036818103283,37.32583483578646,0 127.1036734574299,37.32963047532504,0 127.1036648237874,37.33355328254229,0 127.1035659265014,37.33817448074132,0 127.1035312521025,37.34195072231822,0 127.1035522310146,37.34481895612194,0 127.1035872770438,37.3469847464187,0 127.1035462288227,37.35007356754367,0 127.1035232787103,37.35458585136803,0 127.1034293692482,37.35813441240978,0 127.1034231844963,37.36093935555257,0 127.1034182779115,37.36316446715544,0 127.1037610131883,37.36515968600598,0 127.1036402403194,37.36714669416152,0 127.1033520667065,37.36987044897299,0 127.1033441289947,37.37346811496654,0 127.1033567204447,37.37680922695986,0 127.103354364935,37.38083649065145,0 127.1029946870995,37.38574635647583,0 127.1021052324206,37.38996358440441,0 127.101534540776,37.39342200913732,0 127.1005034206515,37.40008808720609,0 127.0986418658118,37.40250427355908,0 127.0970313954098,37.40459411750128,0 127.0970691184971,37.40540026044128,0 127.0974675176338,37.40614596192169,0 127.098867725053,37.40658093701485,0 127.1020282850031,37.40742208504399,0 127.1029598087956,37.40742327095467,0 127.1039525662723,37.40740979890853,0 127.1050663713609,37.40738178026795,0 127.105951369299,37.40739761931201,0 127.1068513781529,37.4073987646094,0 127.109373054296,37.40769848525543,0 127.1117889237231,37.40755273156242,0 127.1146299874395,37.40835858692826,0 127.1172652269411,37.41004854453938,0 127.1182780138566,37.41098416159339,0 127.1196988838447,37.41324642599366,0 127.1218841887838,37.4161233464998,0 127.1233417788427,37.41963488153956,0 127.1233585492696,37.42394554788019,0 127.123609422192,37.42816913860522,0 127.1237301050672,37.43198715744109,0 127.1235022875553,37.43535075929143,0 127.1225649735398,37.43802854804633,0 127.1230236756198,37.44205659499558,0 127.1256470628831,37.44750717970506,0 127.125504383337,37.45654787252287,0 127.125762524652,37.46411197525981,0 127.1256543737948,37.47161639394621,0 127.1273254725744,37.47381130932114,0 127.1282259685189,37.47405254085835,0 127.1291801350832,37.47394814560919,0 127.1296422752581,37.47334198555615,0 127.1298769377014,37.47204565075865,0 127.1295823692571,37.47121854220264,0 127.1287074245732,37.47077911966471,0 127.1277144942944,37.47095715371091,0 127.1270490482036,37.47158439756853,0 127.1271109791895,37.47252552922202,0 127.1271964136899,37.47527389233365,0 127.1272874706047,37.47725316465517,0 127.1249662066076,37.48114108182269,0 127.1234212770727,37.48414498263981,0 127.1228396793323,37.48550076716733,0 127.1240247950935,37.48567960409262,0 127.1246070658659,37.48571625915248,0 127.1249704722501,37.48572220087037,0 127.1252728321571,37.48581911197421,0 127.1250964763169,37.48603566767955,0 127.1249920236259,37.4862463390524,0 127.1247920612707,37.48625761159696,0 127.1246403490277,37.48623053798139,0 127.1245070045768,37.48624186451396,0 127.1244221414056,37.4862725462474,0 127.1244166518248,37.4863620696677,0 127.1244198332523,37.48648113436864,0 127.1244232603144,37.48658647528962,0 127.1244456246611,37.48665648663765,0"
record = text.split(" ")
'''
date = 1539310850
result=open("new2.txt","w")
with open("new1.txt","rb") as f:
record = f.readlines()
for y in record:
date+=1
x=y.split(",")
result.write(str(date)+","+x[1].strip()+","+x[0]+",0,22.332016013614247\n")
'''
date = 1539310850
for x in record:
date+=1
data=x.split(",")
print str(date)+","+data[1]+","+data[0]+",0,22.545000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment