简体   繁体   中英

Plot points on map in matlab

I tried to plot points on a map in matlab using Plotting Points on a Map in MATLAB but for some reason the point won't appear. This is my code.

figure('visible','on');

    %%% Set the map boundaries
hi_lat=43.86;
lo_lat=41.23;
hi_lon= 6.08;
lo_lon=2.21;

    %%% Plot
worldmap ([lo_lat hi_lat], [lo_lon hi_lon]) % lat and lon bounds of your plot
geoshow('landareas.shp','FaceColor', 'green', 'EdgeColor', [0 0 0])
geoshow('worldcities.shp', 'Marker', '.',...
                       'Color', 'red')
labelLat = 43.5;
labelLon = 5.35;
textm(labelLat, labelLon, 'Marseille')
framem off; gridm off; mlabel off; plabel off
lat=3.13;
lon=42.48;
geoshow(lat,lon, 'DisplayType', 'Point', 'Marker', '+', 'Color', 'red'); %Part of the code that's not doing what I want it to do.

hold on

This gets me the following figure: 在此处输入图片说明

How do I plot this other point? Why will it not appear?

Points you marked on the map do not appear because you have exceeded latitude and longitude limits. Try this;

lat=42.48;
lon=3.13;

Working now! Here is the result: points.jpg

The bug in your code is here:

lat=3.13;
lon=42.48;

You just mixed up lat and lon, so its trying to plot some far away point off the map.

Try:

lat=42.48;
lon=3.13;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM