Plotting Points on a Map in MATLAB

后端 未结 1 675
孤独总比滥情好
孤独总比滥情好 2021-01-06 09:30

I want to plot different locations on a map of NY state. My current code plots the entirety of North America because I couldn\'t find how to plot just one state. I\'m trying

相关标签:
1条回答
  • 2021-01-06 09:59

    You can get a USA state map with usamap('New York') and plot an overlay text with textm. Here, 25 random points and their label are plotted on the figure.

    The following plot

    enter image description here

    is produced by

    latlim = [39 47];
    lonlim = [-81 -70];
    
    figure('Color','w');
    usamap('New York')
    shi = shaperead('usastatehi', 'UseGeoCoords', true,...
                'Selector',{@(name) strcmpi(name,'New York'), 'Name'});
    geoshow(shi, 'FaceColor', [0.3 1.0, 0.675])
    textm(shi.LabelLat, shi.LabelLon, shi.Name, 'HorizontalAlignment', 'center')
    
    nb_point = 25;
    LAT = latlim(1) + (latlim(2)-latlim(1)).*rand(nb_point,1);
    LON = lonlim(1) + (lonlim(2)-lonlim(1)).*rand(nb_point,1);
    h = geoshow(LAT, LON, 'DisplayType', 'Point', 'Marker', '+', 'Color', 'red');
    textm(LAT, LON+0.3, num2str((1:nb_point)'), 'FontSize',14)
    
    0 讨论(0)
提交回复
热议问题