traffic.core.sv
- class traffic.core.sv.StateVectors(data)
Bases:
GeographyMixin
Plots the state vectors returned by OpenSky REST API.
- agg_xy(resolution, projection=None, **kwargs)
Aggregates values of a traffic over a grid of x/y, with x and y computed by
compute_xy()
.- Parameters:
resolution (None | dict[str, float]) – The resolution of the grid is passed as a dictionary parameter. By default, the grid is made by rounding x and y to the lower ten kilometer values.
dict(x=5000, y=3000)
will take 1 value per 5000 meters for x (10000, 15000, 20000, …) and 1 value per 3000 meters for y (9000, 12000, 15000, 18000, 20000, …).projection (None | pyproj.Proj | ‘crs.Projection) – is used to compute the x and y values.
The kwargs specifies how to aggregate values:
altitude="mean"
would average all values in the given cell;timestamp="count"
would return the number of samples per cell;icao24="nunique"
would return the number of different aircraft int the given cell.
- Return type:
pd.DataFrame
- Returns:
a
DataFrame
indexed over x and y values. It is conveniently chainable with the.to_xarray()
method in order to plot density heatmaps.
Example usage:
belevingsvlucht.agg_xy( resolution=dict(x=3e3, y=3e3), vertical_rate="mean", timestamp="count" )
- assign(*args, **kwargs)
Applies the Pandas
assign()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- compute_latlon_from_xy(projection)
Enrich a DataFrame with new longitude and latitude columns computed from x and y columns. :rtype:
Self
Warning
Make sure to use as source projection the one used to compute
'x'
and'y'
columns in the first place.
- compute_xy(projection=None)
Enrich the structure with new x and y columns computed through a projection of the latitude and longitude columns.
The source projection is WGS84 (EPSG 4326). The default destination projection is a Lambert Conformal Conical projection centred on the data inside the dataframe.
Other valid projections are available: :rtype: Self
as
pyproj.Proj
objects;as
cartopy.crs.Projection
objects.
- convert_dtypes(*args, **kwargs)
Applies the Pandas
convert_dtypes()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- drop(*args, **kwargs)
Applies the Pandas
drop()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- drop_duplicates(*args, **kwargs)
Applies the Pandas
drop_duplicates()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- fillna(*args, **kwargs)
Applies the Pandas
fillna()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- classmethod from_file(filename, **kwargs)
Read data from various formats.
This class method dispatches the loading of data in various format to the proper
pandas.read_*
method based on the extension of the filename. Potential compression of the file is inferred by pandas itself based on the extension. :rtype:Self
.pkl.* or .parquet.* dispatch to
pandas.read_pickle()
;.parquet.* dispatch to
pandas.read_parquet()
;.feather.* dispatch to
pandas.read_feather()
;.json.* dispatch to
pandas.read_json()
;.jsonl dispatch to a specific function (output of jet1090);
.csv.* dispatch to
pandas.read_csv()
;.h5.* dispatch to
pandas.read_hdf()
.
Other extensions return None. Specific arguments may be passed to the underlying
pandas.read_*
method with the kwargs argument.Example usage:
>>> from traffic.core import Traffic >>> t = Traffic.from_file(filename)
- geoencode(**kwargs)
Returns an altair encoding of the shape to be composed in an interactive visualization. Specific plot features, such as line widths, can be passed with the kwargs argument. See documentation.
- Return type:
- groupby(*args, **kwargs)
Applies the Pandas
groupby()
method to the underlying pandas DataFrame.- Return type:
DataFrameGroupBy
- leaflet(**kwargs)
Returns a Leaflet layer to be directly added to a Map.
The elements passed as kwargs as passed as is to the Marker constructor.
- Return type:
- merge(*args, **kwargs)
Applies the Pandas
merge()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- plot(ax, s=10, **kwargs)
Plotting function. All arguments are passed to ax.scatter
- Return type:
Artist
- query(query_str, *args, **kwargs)
Applies the Pandas
query()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Optional
[Self
]
- rename(*args, **kwargs)
Applies the Pandas
rename()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- replace(*args, **kwargs)
Applies the Pandas
replace()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- reset_index(*args, **kwargs)
Applies the Pandas
reset_index()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- sort_values(by, **kwargs)
Applies the Pandas
sort_values()
method to the underlying pandas DataFrame and get the result back in the same structure.- Return type:
Self
- to_csv(filename, *args, **kwargs)
Exports to CSV format.
Options can be passed to
pandas.DataFrame.to_csv()
as args and kwargs arguments.Read more: How to export and store trajectory and airspace data?
- Return type:
- to_excel(filename, *args, **kwargs)
Exports to Excel format.
Options can be passed to
pandas.DataFrame.to_excel()
as args and kwargs arguments.Read more: How to export and store trajectory and airspace data?
- Return type:
- to_feather(filename, *args, **kwargs)
Exports to feather format.
Options can be passed to
pandas.DataFrame.to_feather()
as args and kwargs arguments.Read more: How to export and store trajectory and airspace data?
- Return type:
- to_hdf(filename, *args, **kwargs)
Exports to HDF format.
Options can be passed to
pandas.DataFrame.to_hdf()
as args and kwargs arguments.Read more: How to export and store trajectory and airspace data?
- Return type:
- to_json(filename, *args, **kwargs)
Exports to JSON format.
Options can be passed to
pandas.DataFrame.to_json()
as args and kwargs arguments.Read more: How to export and store trajectory and airspace data?
- Return type:
- to_parquet(filename, *args, **kwargs)
Exports to parquet format.
Options can be passed to
pandas.DataFrame.to_parquet()
as args and kwargs arguments.Read more: How to export and store trajectory and airspace data?
- Return type:
- to_pickle(filename, *args, **kwargs)
Exports to pickle format.
Options can be passed to
pandas.DataFrame.to_pickle()
as args and kwargs arguments.Read more: How to export and store trajectory and airspace data?
- Return type: