A Python application for calculating collision avoidance radar plots to help maritime navigators train and practice this essential skill.
- Calculate CPA (Closest Point of Approach)
- Determine maneuvers for collision avoidance
- Visualize radar plots with interactive graphics and vector arrows
- Web interface for non-technical users (Streamlit)
- Python API for advanced users
- Educational tool for Coast Guard Auxiliary and maritime training
The web app provides an intuitive interface for entering vessel parameters and calculating collision avoidance solutions.
Professional polar radar plot showing relative motion lines (RML), closest point of approach (CPA), new relative motion line (NRML), and maneuvering solutions.
The app calculates all essential navigation parameters including CPA distance/bearing, relative motion vectors (SRM/DRM), true motion vectors (STM/DTM), and recommended new course/speed.
# Clone the repository
git clone https://github.com/osyounis/collision_avoidance_radar_plotting_app.git
cd collision_avoidance_radar_plotting_app
# Install with uv (recommended)
uv sync
# Or with pip
pip install -e .# With uv
uv run streamlit run app.py
# Or directly
streamlit run app.pyThen open your browser to http://localhost:8501
- Run the Streamlit app (see above)
- Enter your vessel's course and speed
- Set maneuver parameters (Maneuver Distance and Keep Out Distance)
- Enter contact vessel observations (Point R and Point M)
- Click "Calculate Solution"
from radar_plotter.models import RadarProblem, RadarPoint
from radar_plotter.solver import solver_radar_problem
# Define the problem
problem = RadarProblem(
our_course=0.0,
our_speed=10.0,
maneuver_dist=5.0,
new_cpa_dist=2.5,
r_point=RadarPoint(45.0, 11.5, "14:00"),
m_point=RadarPoint(43.0, 9.0, "14:06")
)
# Solve
solution = solver_radar_problem(problem)
print(f"CPA: {solution.cpa_range:.1f} NM at {solution.cpa_time:%H:%M}")
print(f"New Course: {solution.new_course:.0f}Β°")
print(f"New Speed: {solution.new_speed:.0f} kts")# Run a basic calculation
uv run python examples/basic_calculation.py
# Display an animated radar plot
uv run python examples/animated_plot.pyuv run pytest # Run all tests
uv run pytest -v # Verbose output
uv run pytest --cov=radar_plotter # With coverage
uv run pytest --cov=radar_plotter --cov-report=html # Coverage + HTML reportuv run ruff check . # Linting
uv run ruff format . # Auto-format
uv run mypy src/ # Type checkingsrc/radar_plotter/
βββ core/ # Core calculation modules
β βββ coordinates.py # Polar β Cartesian conversion
β βββ cpa.py # Closest Point of Approach
β βββ maneuvers.py # Collision avoidance maneuvers
β βββ relative_motion.py # SRM/DRM calculations
β βββ true_motion.py # STM/DTM calculations
βββ plotting/ # Visualization
β βββ animation.py # Animated radar plots
β βββ radar_plot.py # Static radar plots
βββ models.py # Data models (RadarProblem, RadarSolution)
βββ solver.py # Main solver orchestration
βββ scenarios.py # Pre-defined test scenarios
Collision Avoidance Radar Plotting is a maritime navigation technique used to:
- Track vessel movements on radar
- Calculate closest point of approach (CPA)
- Determine required maneuvers to avoid collisions
- Comply with COLREGs (International Regulations for Preventing Collisions at Sea)
- CPA: Closest Point of Approach - minimum distance to target
- SRM: Speed of Relative Movement
- DRM: Direction of Relative Movement
- STM: Speed of True Movement
- DTM: Direction of True Movement
- N/C: New Course required to avoid collision
- N/S: New Speed required to avoid collision
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch from
dev - Make your changes
- Run tests and linting:
uv run pytest && uv run ruff check . - Submit a pull request to
dev
This project is licensed under GNU General Public License v3.0 or later (GPL-3.0-or-later).
See LICENSE for full text.
This is an educational tool ONLY. It should NOT be used for real collision avoidance situations. Always follow proper maritime navigation procedures and COLREGs.
Omar Younis
- U.S. Coast Guard Auxiliary for radar plotting training materials
- Northeast Maritime Institute for instructional videos
- Developed with modern Python best practices using
uvand Streamlit


