Skip to contents

Compute Continuous Airspace Visits

Usage

intersect_trajectories(airspaces, flights, progress = FALSE)

Arguments

airspaces

An object returned by init_airspaces in this R session.

flights

A data frame with character id, numeric lon, lat and altitude in feet, and time_over as POSIXct, Unix seconds, or ISO 8601 strings.

progress

If TRUE, print processing stages and segment progress. Default FALSE. Percentages cover segment processing only, not validation, sorting or conversion of the results.

Value

A data frame with one row per flight, airspace and continuous visit. Includes id, airspace_id, visit_id, entry/exit longitude and latitude, entry_altitude_ft, exit_altitude_ft, UTC POSIXct entry_time and exit_time, starts_inside and ends_inside. These flags indicate that recording starts or ends in the airspace, including its boundary; such endpoints are not necessarily observed boundary crossings. No intersections returns a zero-row frame with the same columns and types.

Details

Boundaries are included for positive-duration travel; isolated touches are excluded. Coordinates, altitude and time are linearly interpolated between observations. Separate visits remain separate; overlapping blocks of the same airspace are merged. Distinct overlapping airspaces have separate profiles. Longitude is interpolated along the shorter route across the antimeridian. Segments with exactly 180 degrees of longitude difference are ambiguous and rejected. Polar or globe-winding polygons are not supported.

Examples

directory <- system.file("extdata", package = "rddr")
airspaces <- init_airspaces(file.path(directory, "example.are"),
                           file.path(directory, "example.sls"),
                           file.path(directory, "example.spc"))
flights <- read_trajectories(file.path(directory, "flights.csv"))
intersect_trajectories(airspaces, flights)
#>        id airspace_id visit_id entry_lon entry_lat exit_lon exit_lat
#> 1 EXAMPLE       GROUP        1         0         1        4        1
#> 2 EXAMPLE       GROUP        2         6         1        8        1
#>   entry_altitude_ft exit_altitude_ft          entry_time           exit_time
#> 1             15000            15000 2025-01-01 00:00:10 2025-01-01 00:00:50
#> 2             15000            15000 2025-01-01 00:01:10 2025-01-01 00:01:30
#>   starts_inside ends_inside
#> 1         FALSE       FALSE
#> 2         FALSE       FALSE