コード例 #1
0
import numpy as np
import folium
from folium.plugins import BeautifyIcon
from gpxplotter import (
    create_folium_map,
    read_gpx_file,
    add_segment_to_map,
)
from gpxplotter.common import cluster_velocities

line_options1 = {'weight': 13, 'color': '#006d2c'}
line_options2 = {
    'weight': 8,
}

the_map = create_folium_map(tiles='kartverket_topo4')

for track in read_gpx_file('example3.gpx'):
    for i, segment in enumerate(track['segments']):
        segment['velocity-level'] = cluster_velocities(
            segment['velocity'],
            n_clusters=9,
        )
        add_segment_to_map(the_map,
                           segment,
                           line_options=line_options1,
                           add_start_end=False)
        add_segment_to_map(the_map,
                           segment,
                           color_by='velocity-level',
                           cmap='RdYlGn_09',
コード例 #2
0
"""
Track colored by heart rate zones
=================================

This example will create a map and color the track according
to heart rate zones.
"""
import folium
from gpxplotter import (
    create_folium_map,
    read_gpx_file,
    add_segment_to_map,
    add_tiles_to_map,
)
line_options = {'weight': 8}

the_map = create_folium_map()
add_tiles_to_map(the_map, 'kartverket_topo4', 'kartverket_topo4graatone')
folium.LayerControl(sortLayers=True).add_to(the_map)

for track in read_gpx_file('example3.gpx'):
    for i, segment in enumerate(track['segments']):
        add_segment_to_map(the_map, segment, color_by='hr-zone-float',
                           cmap='viridis', line_options=line_options)

# To store the map as a HTML page:
# the_map.save('map_004.html')

# To display the map in a Jupyter notebook:
the_map
コード例 #3
0
# Copyright (c) 2021, Anders Lervik.
# Distributed under the LGPLv2.1+ License. See LICENSE for more info.
"""
Heart rate heat map
===================

This example will create a map and add a heart rate heat map along
a track.
"""
from folium.plugins import HeatMap
from gpxplotter import read_gpx_file, create_folium_map

the_map = create_folium_map(tiles='openstreetmap')
for track in read_gpx_file('example4.gpx'):
    for i, segment in enumerate(track['segments']):
        data = []
        for lat, lon, hr in zip(segment['lat'], segment['lon'], segment['hr']):
            data.append([lat, lon, float(hr)])
        HeatMap(data, name='Heart rate', radius=20).add_to(the_map)
        boundary = the_map.get_bounds()
        the_map.fit_bounds(boundary, padding=(3, 3))
        break
# To store the map as a HTML page:
# the_map.save('map_010.html')

# To display the map in a Jupyter notebook:
the_map
コード例 #4
0
In this example we will add some images to the map, these
are placed in the map by matching time and location information
from the image.
"""
import datetime
from gpxplotter import create_folium_map, read_gpx_file, add_segment_to_map
import folium
import numpy as np
import PIL
from PIL.ExifTags import TAGS, GPSTAGS


line_options = {'weight': 8}

the_map = create_folium_map()
for track in read_gpx_file('example3.gpx'):
    for i, segment in enumerate(track['segments']):
        add_segment_to_map(the_map, segment, color_by='hr-zone-float',
                           cmap='viridis', line_options=line_options)

# Display initial map:
the_map


# Create a method to get coordinates from an image:
def get_lat_lon(imagefile):
    image = PIL.Image.open(imagefile)
    exif_info = {}
    for key, val in image._getexif().items():
        exif_info[TAGS.get(key, key)] = val