简体   繁体   English

在MATLAB中在地图上绘制点

[英]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. 我试图在MATLAB中使用在MATLAB的地图上绘制点来在matlab的地图上绘制点,但是由于某些原因,该点不会出现。 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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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