How do I plot points on a map in matlab?
56 次查看(过去 30 天)
显示 更早的评论
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
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.
2018-10-15
geoshow(LAT, LON, 'DisplayType', 'Point', 'Marker', '+', 'Color', 'red');
2 个评论
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.
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 Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!