Ich bekomme als Fehlermeldung:
Welchen Fehler mache ich? Es soll eigentlich der dataFrame testweise ausgegeben werden. Er bekommt doch das Argument!runfile('C:/Users/Strawk Work/Documents/Programmierung_ausser_PHP/Python/analysis_of_geo_data/various_calc_from_gpx_file_01.py', wdir='C:/Users/Strawk Work/Documents/Programmierung_ausser_PHP/Python/analysis_of_geo_data')
Traceback (most recent call last):
File "<ipython-input-16-f241b1804623>", line 1, in <module>
runfile('C:/Users/Strawk Work/Documents/Programmierung_ausser_PHP/Python/analysis_of_geo_data/various_calc_from_gpx_file_01.py', wdir='C:/Users/Strawk Work/Documents/Programmierung_ausser_PHP/Python/analysis_of_geo_data')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Strawk Work/Documents/Programmierung_ausser_PHP/Python/analysis_of_geo_data/various_calc_from_gpx_file_01.py", line 57, in <module>
calc1.read_GPX_file()
TypeError: read_GPX_file() missing 1 required positional argument: 'filename'
Hier der Code:
Code: Alles auswählen
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 15 15:50:07 2018
@author: Strawk Work
"""
import gpxpy
import pandas as pd
from geopy import distance
import matplotlib.pyplot as plt
class VariousCalcFromGPXfile:
def __init__(self, filename):
self.filename = filename
def read_GPX_file(self, filename):
gpx_file = open(self.filename, 'r')
gpx = gpxpy.parse(gpx_file)
data = gpx.tracks[0].segments[0].points
df = pd.DataFrame(columns=['lon', 'lat', 'alt', 'time'])
for point in data:
df = df.append({'lon': point.longitude, 'lat' : point.latitude, 'alt' : point.elevation, 'time' : point.time}, ignore_index=True)
dataFrame = df
return dataFrame
print(dataFrame)
def create_list_of_seconds(self, dataFrame):
lstTimestamps = []
lstTwoTimestamps = []
lstSeconds = []
maxTrkPoints = dataFrame.shape[0]
for i in range(0, maxTrkPoints): # extracts time out of the dataFrame
oneTimestamp = (dataFrame['time'][i])
lstTimestamps.append(oneTimestamp)
for i in range(0, maxTrkPoints-1): # order timestamps pairwise
pairOfTimestampsToAppend = (lstTimestamps[i], lstTimestamps[i+1])
lstTwoTimestamps.append(pairOfTimestampsToAppend)
for i in range(1, maxTrkPoints-1): # call calculate_elapsed_time_between_2_points and enlarge list of seconds
time1 = lstTwoTimestamps[i][0]
time2 = lstTwoTimestamps[i][1]
seconds = calculate_elapsed_time_between_2_points(time1, time2)
lstSeconds.append(seconds)
return lstSeconds
if __name__ == "__main__":
# print(read_GPX_file = VariousCalcFromGPXfile('Aljibe_Picacho_2017-03-08_10-32-52.gpx'))
calc1 = VariousCalcFromGPXfile('Aljibe_Picacho_2017-03-08_10-32-52.gpx')
# print(calc1.dataFrame)
calc1.read_GPX_file()