-
-
Notifications
You must be signed in to change notification settings - Fork 218
Description
ENH: Automate Satellite Imagery Background for Dispersion Plots
Is your feature request related to a problem? Please describe.
Currently, the MonteCarlo class allows users to export dispersion ellipses to .kml files for visualization in Google Earth (export_ellipses_to_kml).
However, there is no built-in way to visualize these ellipses against a real-world map background directly within the Python environment (e.g., Jupyter Notebooks or saved logic). Users currently see only a white background with axes, which lacks context regarding the launch site, safety zones, or geographical landmarks.
The only current available option is to manually add a background image to the matplotlib figure.
Describe the solution you'd like
I would like to implement a feature that automatically downloads satellite or terrain imagery (tiles) from the internet to serve as a background for the dispersion plots.
When plotting the impact or apogee dispersion, the code should:
- Calculate the bounding box (min/max Latitude and Longitude) of the simulation data.
- Fetch the corresponding map tiles from a provider (e.g., OpenStreetMap, Esri Satellite, Stamen).
- Render the dispersion ellipses/scatter points on top of this map.
Implementation Details
- Dependencies: We should consider using
contextily(a library designed to add basemaps to matplotlib figures).- Note: Since this might add heavy dependencies (like
geopandasorrasterio), it might be best to implement this as an optional import (i.e., import it inside the method only if the user calls it, or handle theImportErrorgracefully).
- Note: Since this might add heavy dependencies (like
- Coordinate Systems: Be careful with projections. RocketPy uses WGS84 (Lat/Lon). Web map tiles usually use Web Mercator (EPSG:3857). The implementation must handle this conversion to align the points correctly with the image.
Proposed Usage
analysis = MonteCarlo(...)
analysis.simulate(...)
# Standard plot on white background
analysis.plots.ellipses()
# New functionality with map background
analysis.plots.ellipses(background="satellite")
# OR
analysis.plots.ellipses_on_map(provider="Esri.WorldImagery")Acceptance Criteria
- Implement a method to fetch and plot map tiles behind the dispersion data.
- Support at least two types of backgrounds: "Satellite" and "Street/Terrain".
- Handle offline scenarios gracefully (raise a clear warning if the internet is unreachable, rather than crashing).
- Ensure the dispersion ellipses align correctly with the map geography.
Additional Context
- Resources: [Contextily Documentation](https://contextily.readthedocs.io/en/latest/).
- If you don't want to want to use contextly, please dicuss better alternatives below
Metadata
Metadata
Assignees
Labels
Type
Projects
Status