How do I plot points on a map in matlab?
53 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Geoff Hayes
el 11 de Jun. de 2014
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?
Respuestas (1)
Mike D.
el 15 de Oct. de 2018
geoshow(LAT, LON, 'DisplayType', 'Point', 'Marker', '+', 'Color', 'red');
2 comentarios
Rachel Chen
el 7 de Feb. de 2020
I'm not sure why when I changed the color to 'blue' or 'black', it still shows red points
Mike D.
el 7 de Feb. de 2020
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.
Ver también
Categorías
Más información sobre Geographic Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!