Plot polygons defined by the specific points on map

Hi, I'm using mapping toolbox to display some geographical data.
After plotting some lines using 'geoplot'; 'geoshow' or 'patchm' are not working.
How do I plot polygons in geographic coordinates?
I've tried this:
lats= [30 32 31; 29 30 31];
lons = [-102 -103 -104; -100 -103 -101];
geoplot([30 32], [-102 -104])
for i = size(lats,1)
geoshow(lats(i,:),lons(i,:),'DisplayType','polygon');
end
And this is not what I want;
https://mathworks.com/matlabcentral/answers/487959-overlay-polygon-on-geographic-axes
Thank you for your help.

답변 (1개)

millercommamatt
millercommamatt 2021년 7월 8일
There are many ways to do this, but this works.
lats= [30 32 31; 29 30 31];
lons = [-102 -103 -104; -100 -103 -101];
[numrows, ~] = size(lats);
usamap([28 33], [-105 -99]); % create map axis
for ii=1:numrows
patchesm(lats(ii,:),lons(ii,:),'b'); % blue polygons
end

댓글 수: 2

Thanks, but patchesm cannot be used with geoplot either..
I think understand what you're trying to do now. You want to use geo plot types and non-geo plot types together.
The example that you said you didn't want, combined a GeographicAxes with a second hidden axis. I don't think you can combine use of the geo plot type and non-geo plot types any other way. A further complication is that the rulers of a GeographicAxes aren't linear. I don't know how you would get point in one axis to align with the other. Until Mathworks provide better cross compatability for working with GeographicAxes, I'd stick with map axes.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Geographic Plots에 대해 자세히 알아보기

질문:

AJ
2021년 7월 8일

댓글:

2021년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by