Browse Source

update with colours

master
cathaypacific8747 3 years ago
parent
commit
aa8c0f0601
  1. 15
      kml.py
  2. 2
      out.kml
  3. BIN
      path.png

15
kml.py

@ -1,18 +1,27 @@ @@ -1,18 +1,27 @@
import pandas
from fastkml import kml
from fastkml.geometry import Geometry
from fastkml.styles import LineStyle
from fastkml.styles import Style, LineStyle
from shapely.geometry import Point, LineString
from colour import Color
colours = list(Color("#ff0000").range_to(Color("#00ffff"), 256))
k = kml.KML()
d = kml.Document()
line = []
df = pandas.read_csv('combined.csv')
df_s = [(i.lng, i.lat, i.altitude * 0.3048) for i in df.itertuples()]
min_alt, max_alt = min(j[-1] for j in df_s), max(j[-1] for j in df_s)
for j in range(len(df_s)-1):
p = kml.Placemark()
this_alt = (df_s[j][-1] + df_s[j+1][-1]) / 2
this_colour = colours[int((this_alt-min_alt)/(max_alt-min_alt)*255)].hex_l
p = kml.Placemark(styles=[Style(styles=[LineStyle(
color=f'ff{this_colour[5:7]}{this_colour[3:5]}{this_colour[1:3]}',
width=2
)])])
p.geometry = Geometry(geometry=LineString([
Point(*df_s[j]),
Point(*df_s[j+1]),

2
out.kml

File diff suppressed because one or more lines are too long

BIN
path.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1010 KiB

After

Width:  |  Height:  |  Size: 870 KiB

Loading…
Cancel
Save