Plotting¶
Interactive maps and altitude profile visualizations for flight plans and flight lines.
Maps¶
- map_flight_lines(flight_lines, center=None, zoom_start=6, line_color='blue', line_weight=3)[source]¶
Create an interactive folium map displaying a list of FlightLine objects.
- Parameters:
flight_lines (List[FlightLine]) – List of FlightLine objects to display.
center (tuple, optional) – A tuple (latitude, longitude) to center the map. If None, the center is computed as the average of the start points.
zoom_start (int, optional) – Initial zoom level for the map (default is 6).
line_color (str, optional) – Color for the flight lines (default is “blue”).
line_weight (int, optional) – Thickness of the flight lines (default is 3).
- Returns:
A folium Map object with the flight lines added.
- Return type:
folium.Map
- map_airspace(airspaces, flight_lines=None, conflicts=None, near_misses=None, center=None, zoom_start=8)[source]¶
Create an interactive Folium map with airspace overlays.
Airspace polygons are displayed as GeoJSON with hover tooltips showing name, class, altitude, schedule, and severity. Flight lines are color-coded by conflict status. Layer groups allow toggling by type.
- Parameters:
airspaces – List of Airspace objects.
flight_lines – Optional list of flight line objects.
conflicts – Optional list of AirspaceConflict objects.
near_misses – Optional list of near-miss AirspaceConflict objects.
center – (lat, lon) map center; auto-computed if None.
zoom_start – Initial zoom level.
- Return type:
Map- Returns:
folium.Map with all layers.
- plot_oceanic_tracks(tracks, flight_lines=None, title='Oceanic Tracks', figsize=(16, 8), projection=None)[source]¶
Plot NAT or PACOT oceanic tracks on a wide-projection cartopy map.
Tracks are colored by direction: green=eastbound, blue=westbound. Waypoints are labeled along each track.
- Parameters:
tracks – List of OceanicTrack objects.
flight_lines – Optional list of flight lines to overlay.
title – Plot title.
figsize – Figure size tuple.
projection – Cartopy projection; defaults to PlateCarree.
- Returns:
Matplotlib Figure and Axes.
Flight plan visualization¶
- plot_flight_plan(flight_plan_gdf, takeoff_airport, return_airport, flight_sequence)[source]¶
Plot the computed flight plan on a 2D map with airports, waypoints, and flight lines.
- Parameters:
flight_plan_gdf (GeoDataFrame) – Flight plan from compute_flight_plan().
takeoff_airport (Airport) – Departure airport (plotted as red star).
return_airport (Airport) – Arrival airport (plotted as blue star).
flight_sequence (list) – Sequence of FlightLine, Pattern, and/or Waypoint objects. Patterns are rendered by drawing each of their internal FlightLine legs (line-based) or Waypoint elements (waypoint-based) with the pattern name as the legend label on the first child only.
- Return type:
- plot_altitude_trajectory(flight_plan_gdf, aircraft=None, dem_file=None, show_terrain=True)[source]¶
Plot altitude vs. time trajectory with optional terrain profile.
If an Aircraft is provided, climb/takeoff segments are drawn with the realistic curved profile (ROC decreases with altitude). Otherwise all segments are drawn as straight lines.
- Parameters:
flight_plan_gdf (GeoDataFrame) – Flight plan from compute_flight_plan().
aircraft (Aircraft, optional) – Aircraft used for the flight plan.
dem_file (str, optional) – Path to DEM file for terrain. If None, auto-downloaded.
show_terrain (bool) – If True, overlay terrain elevation beneath the flight path.
- Return type:
- plot_vertical_profile(flight_line, airspaces, dem_file=None, title=None, figsize=(12, 5))[source]¶
Plot an altitude cross-section along a flight line showing airspace bands.
X-axis is distance along the route (NM), Y-axis is altitude (ft MSL). Airspace floors and ceilings are shown as colored bands.
- Parameters:
flight_line – A single flight line object.
airspaces – List of Airspace objects to check.
dem_file – Optional DEM GeoTIFF path for terrain profile.
title – Plot title; auto-generated if None.
figsize – Figure size tuple.
- Returns:
Matplotlib Figure and Axes.
Airspace visualization¶
- plot_airspace_map(airspaces, flight_lines=None, conflicts=None, near_misses=None, inactive_airspaces=None, title='Airspace Map', figsize=(14, 10), show_labels=True, buffer_m=None, extent=None)[source]¶
Plot airspaces, flight lines, conflicts, and near-misses on a cartopy map.
- Parameters:
airspaces – List of Airspace objects to display.
flight_lines – Optional list of flight line objects.
conflicts – Optional list of AirspaceConflict objects.
near_misses – Optional list of AirspaceConflict with severity=”NEAR_MISS”.
inactive_airspaces – Optional list of schedule-filtered airspaces to show grayed out.
title – Plot title string.
figsize – Figure size tuple.
show_labels – If True, label airspaces with name and altitude.
buffer_m – If set, draw a buffer halo around near-miss airspaces.
- Returns:
Matplotlib Figure and Axes.
- plot_conflict_matrix(flight_lines, airspaces, title='Conflict Matrix', figsize=None)[source]¶
Plot a flight-line vs. airspace conflict matrix.
Cells are colored: RED = full conflict, ORANGE = horizontal-only (altitude clear), GRAY = no intersection.
- Parameters:
flight_lines – List of flight line objects.
airspaces – List of Airspace objects.
title – Plot title.
figsize – Optional figure size; auto-sized if None.
- Returns:
Matplotlib Figure and Axes.
Isochrone visualization¶
- plot_isochrone_static(layers, *, points=(), title='', figsize=(9, 9), wind_field=None, wind_altitude=None, wind_time=None, wind_caption=None, basemap_scale='50m', show_refuel_markers=True)[source]¶
Render one or more isochrones on a static Cartopy basemap.
Companion to
hyplan.plot_isochrone(the Folium / interactive plotter). This produces publication-quality figures with Natural Earth vector basemaps and is the right choice for static output (papers, briefings, reports).- Parameters:
layers – Either a single
gpd.GeoDataFramefromcompute_isochrone(),compute_refuel_isochrone(), orcompute_concentric_isochrones(); or an iterable of(gdf, color, label)tuples for layered comparison (e.g., still-air vs. windy). When a single concentric GDF is passed without explicit splitting, the function auto-groups rows bybudget_hrand renders each contour with a viridis-indexed color.points – Iterable of
{"lat", "lon", "label", "color", "marker", "markersize"}dicts for airports / waypoints of interest.title (
str) – Figure title.wind_field – Optional
WindFieldprovider — when supplied, samples wind on a grid covering the plot extent and overlays as aviation-convention wind barbs (half-barb 5 kt, full barb 10 kt, flag 50 kt).wind_altitude – Altitude (Quantity) for wind queries; required when
wind_fieldis supplied.wind_time – UTC datetime to query the wind at; defaults to now.
wind_caption (
Optional[str]) – Optional caption drawn in the corner.basemap_scale (
str) – Natural Earth resolution:"110m"(lowest, ships with cartopy),"50m"(default), or"10m"(highest; downloads on first use).show_refuel_markers (
bool) – When True (default) and the input GDF hasattrs["refuel_airports_evaluated"], draw refuel airport markers (used = darkblue, evaluated-not-used = gray, unreachable = light gray).
- Returns:
(fig, ax)so the caller can add overlays after.
plot_isochrone_static is the static (Cartopy) companion to the
interactive Folium plot_isochrone (in hyplan.planning). Use it
for publication-quality figures and layered comparisons (still-air
vs. windy, multi-budget concentric reach, refuel scenarios).
Terrain¶
- terrain_profile_along_track(flight_plan_gdf, dem_file=None)[source]¶
Sample terrain elevation along the flight plan track.
Extracts lat/lon points from each segment geometry, queries DEM elevation, and returns arrays of cumulative time and terrain height.
- Parameters:
flight_plan_gdf (GeoDataFrame) – Flight plan from compute_flight_plan().
dem_file (str, optional) – Path to DEM file. If None, one is auto-downloaded.
- Returns:
- (times, elevations) where times is cumulative minutes and
elevations is terrain height in feet MSL, both as numpy arrays.
- Return type: