-
Notifications
You must be signed in to change notification settings - Fork 33
/
examples.py
63 lines (49 loc) · 2.71 KB
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
# Copyright 2017 Juan José Martín Miralles
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Own modules
import trackanimation
from trackanimation.animation import AnimationTrack
# Simple example
input_directory = "example-routes/"
ibiza_trk = trackanimation.read_track(input_directory)
fig = AnimationTrack(df_points=ibiza_trk, dpi=300, bg_map=True, map_transparency=0.5)
fig.make_video(output_file='simple-example', framerate=60, linewidth=1.0)
# Filtering by place and normalizing
input_directory = "example-routes/"
ibiza_trk = trackanimation.read_track(input_directory)
sant_josep_trk = ibiza_trk.get_tracks_by_place('Sant Josep de sa Talaia', only_points=False)
sant_josep_trk = sant_josep_trk.time_video_normalize(time=10, framerate=10)
fig = AnimationTrack(df_points=sant_josep_trk, dpi=300, bg_map=True, map_transparency=0.5)
fig.make_video(output_file='filtering-by-place', framerate=10, linewidth=1.0)
# Coloring tracks by their speed
input_directory = "example-routes/ibiza.csv"
ibiza_trk = trackanimation.read_track(input_directory)
ibiza_trk = ibiza_trk.time_video_normalize(time=10, framerate=10)
ibiza_trk = ibiza_trk.set_colors('Speed', individual_tracks=True)
fig = AnimationTrack(df_points=ibiza_trk, dpi=300, bg_map=True, map_transparency=0.5)
fig.make_video(output_file='coloring-map-by-speed', framerate=10, linewidth=1.0)
# Variable 'bg_map' must be to False in order to create an interactive map
fig = AnimationTrack(df_points=ibiza_trk, dpi=300, bg_map=False, map_transparency=0.5)
fig.make_map(output_file='coloring-map-by-speed')
# Multiple axes
input_directory = "example-routes/"
ibiza_trk = trackanimation.read_track(input_directory)
sant_josep_trk = ibiza_trk.get_tracks_by_place('Sant Josep de sa Talaia', only_points=False)
ibiza_trk = ibiza_trk.set_colors('Speed', individual_tracks=True)
sant_josep_trk = sant_josep_trk.set_colors('Speed', individual_tracks=True)
fig = AnimationTrack(df_points=[ibiza_trk, sant_josep_trk], dpi=300, bg_map=True, aspect='equal', map_transparency=0.5)
fig.make_image(output_file='multiple-axes-equal')
fig = AnimationTrack(df_points=[ibiza_trk, sant_josep_trk], dpi=300, bg_map=True, aspect='auto', map_transparency=0.5)
fig.make_image(output_file='multiple-axes-auto')