How do I plot points on a map in matlab?

57 ビュー (過去 30 日間)
Shane
Shane 2014 年 6 月 10 日
コメント済み: Mike D. 2020 年 2 月 7 日
I have the mapping toolbox function. I brought up a map of the U.S. with lat/lon axes. All I need to do now I plot points on the map where certain cities/areas are. It does not need to be exact (but preferred), so any type of brush or something would work. How do I do this?
Here is what I have so far:
figure; ax = usamap({'CA','ME'});
set(ax, 'Visible', 'off')
latlim = getm(ax, 'MapLatLimit');
lonlim = getm(ax, 'MapLonLimit');
states = shaperead('usastatehi',...
'UseGeoCoords', true, 'BoundingBox', [lonlim', latlim']);
geoshow(ax, states, 'FaceColor', [0.5 0.5 1])
lat = [states.LabelLat];
lon = [states.LabelLon];
tf = ingeoquad(lat, lon, latlim, lonlim);
textm(lat(tf), lon(tf)) ...
  1 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 6 月 11 日
Unfortunately, I don't have the Mapping Toolbox, but at one time I did…and the use of textm was something I used to write annotation to the map given a latitude and longitude pair. Is that what you are doing? I also used plotm to "insert" shapes at certain locations too. Where are you getting stuck?

サインインしてコメントする。

回答 (1 件)

Mike D.
Mike D. 2018 年 10 月 15 日
geoshow(LAT, LON, 'DisplayType', 'Point', 'Marker', '+', 'Color', 'red');
  2 件のコメント
Rachel Chen
Rachel Chen 2020 年 2 月 7 日
I'm not sure why when I changed the color to 'blue' or 'black', it still shows red points
Mike D.
Mike D. 2020 年 2 月 7 日
There is more than one way to change the color. You can interactively do it by clicking on the Edit Plot icon in the figure window (white arrow), then click on the symbol or text or curve item, then right-click and select 'Color'. I see what you mean that it still stays red. If you highlight the symbol, then type "get(gco)" in the command window, it will show the properties. It shows 'Color' property was modified correctly, but the 'MarkerEdgeColor' seems to be the dominating property for what color is displayed. Thus, you want to change the 'MarkerEdgeColor' instead of the 'Color' property. The command that created this symbol is the geoshow function (Mapping Toolbox function) and the resulting object it creates is technically a "Line" object. If you set the 'MarkerEdgeColor' to be 'auto', then the 'Color' property will work as specified.
Just so you know, Matlab R2018b came out with a new geoaxes function in core Matlab that doesn't require MappingToolbox and creates fantastic maps that easily pan/zoom with a mouse, are highly customizable. Geoaxes figures are much easier to create than Mapping Toolbox figures, but MappingToolbox figures are better in showing proper projections.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by