Tutorial 5-E: Airport & Port Visualization
Purpose
This notebook demonstrates how to use Tracktable’s airport and port databases to populate a map. Tracktable has numerous rendering methods, and not all are shown here. A comprehensive rendering user guide can be found in the Tracktable documentation: https://tracktable.readthedocs.io/en/latest/user_guides/python/rendering.html
IMPORTANT: When rendering trajectories interactively, the memory required to render large lists of trajectories may cause your browser to shut down. Try rendering smaller datasets first and work up from there to test your browser’s capacity.
In [1]:
import tracktable.examples.tutorials.tutorial_helper as tutorial
from tracktable.render.render_trajectories import render_trajectories
from tracktable.render.render_heatmap import render_heatmap
from tracktable.render.backends import folium_backend
from tracktable.domain.terrestrial import BoundingBox
Instantiating a blank map
We include a tutorial helper function, generate_blank_folium_map(), to generate a blank Folium map as well as this create_map() wrapper for easily resetting and creating a Folium map. create_map() will be called throughout this tutorial to reset the map between examples. If the map is not reset then markers and dots for airports and ports will be continually added
to the map.
In [2]:
# Folium needs two corner points for bounding boxes: [sw, ne], in (lat,lon) order
# For most of this tutorial we will be setting the bounding box of the folium map to CONUS.
def create_map(bbox=[(22,-130),(50,-65)]):
return tutorial.generate_blank_folium_map(bbox=bbox,
tiles='cartodbdark_matter', attr=".", crs="EPSG3857",
control_scale=True,
max_zoom=22,
prefer_canvas=True)
Rendering Airports
Rendering airports on to a folium map is as simple as calling the render_airports_and_ports() function with the generated folium map from above as well as a list of ICAO/IATA codes of the airports which should be rendered, a bounding box in which to render all airports or both at the same time. Each marker/dot rendered onto the map has a tooltip and popup window which provides the following information about the given airport.
Name
City
Country
Lat, Lon, Alt (Feet & Meters)
IATA Code
ICAO Code
UTC Offset
Daylight Savings
By default, when rendering airports, if no airport list or bounding box is provided all airports in the database will be rendered onto the map.
Note: If the use_markers flag is set to True there will be a significant performance slowdown when viewing the map.
In [3]:
fol_map_canvas = create_map(bbox=None)
folium_backend.render_airports_and_ports(fol_map_canvas,
draw_airports=True
)
fol_map_canvas
Out[3]: