Airports

class Airport[source]

Bases: object

An airport looked up by ICAO code from the OurAirports dataset.

Lazily initializes global airport data on first instantiation. Properties provide access to location, elevation, and runway information.

Parameters:

icao (str) – ICAO code of the airport (e.g., “KJFK”).

Raises:

ValueError – If the ICAO code is not found in the dataset.

__init__(icao)[source]
Parameters:

icao (str)

property longitude

Longitude of the airport.

property latitude

Latitude of the airport.

property geometry

Shapely Point geometry of the airport.

property icao_code

ICAO code of the airport.

property iata_code

IATA code of the airport.

property name

Name of the airport.

property country

ISO country code of the airport.

property municipality

Municipality of the airport.

property elevation

Elevation of the airport in meters. Returns None if not available.

property elevation_ft

Elevation of the airport in feet. Returns None if not available.

property runways: pandas.DataFrame

Runway details for this airport as a DataFrame.

initialize_data(countries=None, min_runway_length=None, runway_surface=None, airport_types=None, cache_dir=None, refresh=False)[source]

Initialize global variables for airports and runways data with filtering options.

Parameters:
  • countries (List[str]) – ISO country codes to filter airports by.

  • min_runway_length (int) – Minimum runway length in feet.

  • runway_surface (Union[str, List[str]]) – Runway surface type(s) to filter by.

  • airport_types (List[str]) – Airport types to include (default: large, medium, small).

  • cache_dir (Union[str, Path]) – Directory to store downloaded data files. Defaults to ~/.cache/hyplan/.

  • refresh (bool) – If True, re-download data files even if they already exist.

Return type:

None

find_nearest_airport(lat, lon)[source]

Find the nearest airport to a given latitude and longitude.

Returns:

ICAO code of the nearest airport.

Return type:

str

Parameters:
find_nearest_airports(lat, lon, n=5)[source]

Find the N nearest airports to a given latitude and longitude.

Returns:

ICAO codes of the nearest airports, ordered by proximity.

Return type:

List[str]

Parameters:
airports_within_radius(lat, lon, radius, unit='kilometers', return_details=False)[source]

Find all airports within a specified radius of a given point.

Parameters:
  • lat (float) – Latitude of the center point.

  • lon (float) – Longitude of the center point.

  • radius (float) – Search radius.

  • unit (str) – Distance unit for radius (default: “kilometers”).

  • return_details (bool) – If True, return a GeoDataFrame with a ‘distance_m’ column instead of a list of ICAO codes.

Return type:

Union[List[str], GeoDataFrame]

Returns:

List of ICAO codes, or a GeoDataFrame if return_details is True.

get_airports()[source]

Get the globally initialized GeoDataFrame of airports.

Return type:

GeoDataFrame

get_runways()[source]

Get the globally initialized DataFrame of runways.

Return type:

DataFrame

get_airport_details(icao_codes)[source]

Get details of airports for given ICAO code(s).

Return type:

DataFrame

Parameters:

icao_codes (str | List[str])

get_longest_runway(icao)[source]

Return the length in feet of the longest runway at the given airport.

Returns:

Longest runway length in feet, or None if no runway data is available.

Return type:

float

Parameters:

icao (str)

generate_geojson(filepath='airports.geojson', icao_codes=None)[source]

Generate a GeoJSON file of the airports using GeoPandas with CRS explicitly set to EPSG:4326.

Parameters:
  • filepath (str) – Path to save the GeoJSON file. Defaults to “airports.geojson”.

  • icao_codes (Union[str, List[str]]) – List of ICAO codes to subset the GeoJSON. If None, export all airports.

Return type:

None

get_runway_details(icao_codes)[source]

Retrieve details of all runways for one or more airports.

Parameters:

icao_codes (Union[str, List[str]]) – A single ICAO code or a list of ICAO codes.

Returns:

A DataFrame with runway details for the given airport(s).

Return type:

pd.DataFrame