MATLAB映射工具箱 - 如何将lat / lon坐标绘制到创建的地图上?

时间:2014-07-11 22:05:18

标签: plot maps latitude-longitude matlab

我有这张我用以下代码生成的加州地图:

states = geoshape(shaperead('usastatehi', 'UseGeoCoords', true));
figure
ax = usamap('california');
oceanColor = [.5 .7 .9];
setm(ax, 'FFaceColor', oceanColor)
geoshow(states)
title({ 'California map'})

现在我想使用纬度和经度坐标在地图上绘制特定点。我不能“猜测”,因为我必须绘制100左右的积分。我怎么做?我到处寻找,找不到语法。谢谢。

1 个答案:

答案 0 :(得分:1)

分别使用plotmlinem,相当于MATLAB的plotline函数(它们接受相同的“线型规范”)。

以下是一个例子:

% California map axes
figure; ax = usamap('california');
setm(ax, 'FFaceColor', [.5 .7 .9])
title('California map')

% read shapefile of US states with names and locations
states = geoshape(shaperead('usastatehi.shp', 'UseGeoCoords', true));

% display map
geoshow(states, 'Parent',ax)

% find states within the shown axes limits (California and Nevada)
latlim = getm(ax, 'MapLatLimit');
lonlim = getm(ax, 'MapLonLimit');
idx = ingeoquad(states.LabelLat, states.LabelLon, latlim, lonlim);

% latitude/longitude coordinates and corresponding labels
lat = states(idx).LabelLat;
lon = states(idx).LabelLon;
txt = states(idx).Name;

% plot coordinates
%plot(lat, lon, 'rx')
linem(lat, lon, 'LineStyle','none', 'LineWidth',2, 'Color','r', ...
    'Marker','x', 'MarkerSize',10)
textm(lat, lon, txt, 'HorizontalAlignment', 'left', 'VerticalAlignment','top')

plot_lon_lat_coordinates