How do I plot points on a map in matlab?
조회 수: 57 (최근 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!