Adding Geo-referenced Map as Background in MATLAB Plot

55 次查看(过去 30 天)
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!

回答(1 个)

Piyush Kumar
Piyush Kumar 2024-10-27,7:36
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 个评论
Walter Roberson
Walter Roberson 2024-10-27,7:43

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

Likewise fill() must be replaced by fillm()

Elio
Elio 2024-10-27,11:54
I don't think geoshow will work since I'm using a local reference frame. I know the geographic coordinates of only two points.

请先登录,再进行评论。

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by