In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import io as fio
fname = 'C:/Users/styler/workspace/illah/20100227.gpx'
ft = fio.open(fname)
ft.close()
In [16]:
import xml.etree.ElementTree as ET
tree = ET.parse(fname)
root = tree.getroot()
In [17]:
print root.keys
In [18]:
root.attrib
Out[18]:
In [19]:
def get_element_by_tag(element, tag):
if element.tag.endswith(tag):
yield element
for child in element:
for g in get_element_by_tag(child, tag):
yield g
In [20]:
def stripnamespace(xmltree):
for node in xmltree.getiterator():
if '}' in node.tag:
node.tag = node.tag.split('}', 1)[1]
In [21]:
stripnamespace(root)
root.getchildren()
Out[21]:
In [22]:
root.getchildren()[1].getchildren()[1].getchildren()[0].getchildren()[1].text
Out[22]:
In [23]:
vals = list()
for node in root.iter('trkpt'):
vals.append(dict(node.items()+[('ele',node.getchildren()[0].text),('time',node.getchildren()[1].text)]))
In [24]:
lats = [val['lat'] for val in vals]
lons = [val['lon'] for val in vals]
In [25]:
plt.plot(lons,lats)
Out[25]:
In [2]:
import pandas
fname2 = '/Users/astyler/projects/ChargeCarData/csv/illah20100227_1.csv'
df = pandas.read_csv(fname2)
df.dtypes
#convert_numeric=True)
Out[2]:
In [3]:
df.head()
Out[3]:
In [4]:
#%pylab inline
#df.plot(x='Longitude',y='Latitude',c='Power')
%matplotlib notebook
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
p = plt.figure().gca(projection='3d')
p.plot(df.Longitude, df.Latitude, df.Power)
p.set_xlabel('Lon')
p.set_ylabel('Lat')
p.set_zlabel('Power')
plt.show()
In [9]:
p2 = plt.figure()
p.plot(df.Longitude, df.Latitude)
plt.show()
In [38]:
bp.show(p2)
In [35]:
import plotly.plotly as py
from plotly.graph_objs import *
data = [Scatter3d(x=df.Longitude, y=df.Latitude, z=df.Power,mode='lines')]
py.iplot(data, filename = 'basic-line')
Out[35]:
In [ ]: