- Load the Geo-referenced Map: Use the geoshow function to display the map.
- Overlay Your Plot: Plot your waypoints and other elements on top of the map.
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!
0 个评论
回答(1 个)
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 -
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
2024-10-27,7:43
Notice that plot() had to be replaced by plotm()
Likewise fill() must be replaced by fillm()
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!