Plot polygons defined by the specific points on map
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
millercommamatt
on 8 Jul 2021
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 Comments
millercommamatt
on 12 Jul 2021
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.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!