Altitude Graph
Data Used
GPS track data using smartphone - OSMTracker app. The track-point-data was converted to gpkg.
Create line data from track-point
- Track point was saved to POSTGIS and then polyline data was created by joining two consecutive points using the following SQL.
```{sql}
create table trackline as
(select t1.fid, st_makeline(t1.geom, t2.geom) as lgeom,
.geom, t2.geom) as dist , t2.ele
st_distance(t1from track20190409 t1, track20190409 t2
where t2.fid = t1.fid + 1
)```
- Primary key fid was added
- The postgis table (polyline) was exported again to the geopackage.
- The geopackage file can be read using the following python code.
- Distance vs elevation is plotted using Matplotlib
```{python}
#-------------Use fiona, numpy and matplotlib------
import fiona
import matplotlib.pyplot as plt
import numpy as np
#-----------------------------------------------------------
= []
x = []
y = 0
i #------------------------
## Open gpkg layer
#------------------------
with fiona.open('../mystuffs/data/gnss.gpkg', layer='trkline') as layer:
for feature in layer:
if (i%500 == 0):
print(i)
#~ break
for key, value in feature['properties'].items():
if key=='dist':
if i > 0:
float(value) + x[i-1])
x.append(else:
float(value))
x.append(else:
float(value))
y.append(+= 1
i = np.array(x) * 0.001
xx = np.array(y)
yy #---------------Plot bar
=[12, 6])
plt.figure(figsize"Distance from Bardibas(km)")
plt.xlabel("Elevation(m)")
plt.ylabel(
plt.bar(xx, yy)#---------------Save file-------
"test.svg")
plt.savefig(#--------------------------------
```
Plotted graph is shown below.