Adding Geo-referenced Map as Background in MATLAB Plot

25 Ansichten (letzte 30 Tage)
Elio
Elio am 26 Okt. 2024
Kommentiert: Elio am 27 Okt. 2024
I have a complex figure that combines several plots, including a plot of waypoints marking the path for a drone. I know the geographic coordinates of two of these waypoints and I want to add a geo-referenced map as the background for the figure. Basically, I want the path (and the other elements) to be shown on a geographic map in the corresponding location.
How can I achieve this? Everything I've tried didn't work. I think it's because the figure is too complex; it needs something much simpler than the usual approaches. Any code snippets or guidance on how to overlay a map on my existing plot would be greatly appreciated!
Thank you!

Antworten (1)

Piyush Kumar
Piyush Kumar am 27 Okt. 2024
To add a geo-referenced map as a background to your MATLAB plot, you can follow these simple steps -
  1. Load the Geo-referenced Map: Use the geoshow function to display the map.
  2. Overlay Your Plot: Plot your waypoints and other elements on top of the map.
For example,
% Load the geo-referenced map
figure;
worldmap('World');
geoshow('landareas.shp', 'FaceColor', [0.5 1.0 0.5]);
% Plot your waypoints (example coordinates)
lat = [34.0522, 36.1699, 40.7128]; % Latitude
lon = [-118.2437, -115.1398, -74.0060]; % Longitude
geoshow(lat, lon, 'DisplayType', 'point', 'Marker', 'o', 'Color', 'r');
% Add your custom plot elements
hold on;
% Example: plot a line connecting the waypoints
plotm(lat, lon, 'r-');
  2 Kommentare
Walter Roberson
Walter Roberson am 27 Okt. 2024

Notice that plot() had to be replaced by plotm()

Likewise fill() must be replaced by fillm()

Elio
Elio am 27 Okt. 2024
I don't think geoshow will work since I'm using a local reference frame. I know the geographic coordinates of only two points.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by