lt_toolbox.TrajFrame.filter_polygon#
- TrajFrame.filter_polygon(xy_vars: list, x_poly: list, y_poly: list, drop: bool = False) Self[source]#
Filter trajectories which intersect a specified polygon.
Filtering returns the complete trajectories of particles which have been inside the boundary of a given polygon at any point in their lifetime.
- Parameters:
xy_vars (list(str)) – List of x and y coordinate column variable names.
x_poly (list) – List of x-coordinates representing the boundary of the polygon.
y_poly (list) – List of y-coordinates representing the boundary of the polygon.
drop (bool, default: False) – Determines if fitered trajectories should be returned as a new TrajFrame (False) or instead dropped from the existing TrajFrame (True).
- Returns:
TrajFrame including the complete Lagrangian trajectories which meet (do not meet) the specified filter condition.
- Return type:
TrajFrame
Examples
Filtering all trajectories which intersect a simple square polygon:
>>> x_square = [-40, -40, -30, -30, -40] >>> y_square = [30, 35, 35, 30, 30] >>> trajectories.filter_polygon(xy_vars=['x','y'], x_poly=x_square, y_poly=y_square, drop=False)