Plot polygons defined by the specific points on map
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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 件のコメント
millercommamatt
2021 年 7 月 12 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!