Plot polygons defined by the specific points on map

2 visualizaciones (últimos 30 días)
AJ
AJ el 8 de Jul. de 2021
Comentada: millercommamatt el 12 de Jul. de 2021
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.

Respuestas (1)

millercommamatt
millercommamatt el 8 de Jul. de 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 comentarios
AJ
AJ el 9 de Jul. de 2021
Thanks, but patchesm cannot be used with geoplot either..
millercommamatt
millercommamatt el 12 de Jul. de 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.

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by