- 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
27 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Piyush Kumar
on 27 Oct 2024
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 Comments
Walter Roberson
on 27 Oct 2024
Notice that plot() had to be replaced by plotm()
Likewise fill() must be replaced by fillm()
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!