Created
February 19, 2019 03:42
-
-
Save ivder/19587011c907794696c9e37b61d4e83c to your computer and use it in GitHub Desktop.
Convert GPS information from text to KML format that can be viewed with Google Earth (1 KML file for all coordinate point)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simplekml | |
import os | |
def kml_converter(inputfile,kml): | |
f = open(inputfile,"r") | |
for row in f: | |
data=row.split(",") | |
splitdata=data[0].split("\\") | |
kml.newpoint(name=splitdata[6], coords=[(data[2],data[1])]) | |
'''if not os.path.exists(dirlist): | |
os.makedirs(dirlist) | |
kml.save(dirlist+"/"+filelist+'.kml')''' | |
f.close() | |
#main | |
for root, dirs, files in os.walk("C:\\DeepEye\\Data\\Result\\resources\\20180724_GoPro6"): | |
kml=simplekml.Kml() | |
for filelist in files: | |
if filelist.endswith(".txt"): | |
inputfile=os.path.join(root, filelist) | |
dirlist=os.path.basename(os.path.normpath(root)) | |
kml_converter(inputfile,kml) | |
kml.save(dirlist+'.kml') | |
kml=None | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment