Skip to content

ENH: Automatically downloads satellite images from the internet #890

@Gui-FernandesBR

Description

@Gui-FernandesBR

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:

  1. Calculate the bounding box (min/max Latitude and Longitude) of the simulation data.
  2. Fetch the corresponding map tiles from a provider (e.g., OpenStreetMap, Esri Satellite, Stamen).
  3. 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 geopandas or rasterio), 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 the ImportError gracefully).
  • 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

Metadata

Metadata

Assignees

Labels

EnhancementNew feature or request, including adjustments in current codesGood first issueGood for newcomersMonte CarloMonte Carlo and related contents

Projects

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions