Adding Geo-referenced Map as Background in MATLAB Plot
이전 댓글 표시
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개)
To add a geo-referenced map as a background to your MATLAB plot, you can follow these simple steps -
- 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.
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일
Notice that plot() had to be replaced by plotm()
Likewise fill() must be replaced by fillm()
Elio
2024년 10월 27일
카테고리
도움말 센터 및 File Exchange에서 Vector and Raster Map Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
