Overlay polygon on geographic axes

25 vues (au cours des 30 derniers jours)
Caroline Nowlan
Caroline Nowlan le 29 Oct 2019
Commenté : Mike D. le 29 Avr 2024
I would like to overlay a patch (filled polygon) on a geographic axis created using geoaxes. Is there any way to do this in R2019b? I have only found functions for plotting lines and symbols (geoplot, geoscatter).
This would be similar to patchm in the mapping toolbox.

Réponse acceptée

Subhadeep Koley
Subhadeep Koley le 1 Nov 2019
You can use the patch() function to achieve the same. Use the code below.
% Plot your Geo data here
latSeattle = 47.62;
lonSeattle = -122.33;
latAnchorage = 61.20;
lonAnchorage = -149.9;
gx = geoaxes;
geoplot(gx,latSeattle,lonSeattle);
geobasemap(gx,'landcover');
% Plot your Patch data here
ax2 = axes;
x = [0.25 0.6 0.6 0.25]; % Modify x coordinates of the polygon
y = [0.25 0.25 0.4 0.4]; % Modify y coordinates of the polygon
patch(ax2, x, y,'red','FaceAlpha',.4); % Modify patch color and transparency
axis([0 1 0 1]);
% Set ax2 visibility to 'off'
ax2.Visible = 'off';
ax2.XTick = [];
ax2.YTick = [];
geoPatch.png
  2 commentaires
Caroline Nowlan
Caroline Nowlan le 1 Nov 2019
Works perfectly. Thanks!
Evan Bates
Evan Bates le 6 Jan 2021
Does not work with appdesigner.

Connectez-vous pour commenter.

Plus de réponses (1)

Mike D.
Mike D. le 21 Fév 2020
What if you had (lat,lon) coordinates of the polygon you wanted to overlay? It looks like your x and y coordinates might be normalized coordinates?
  4 commentaires
Brad Onstott
Brad Onstott le 11 Fév 2023
Mike D: Good call! MATLAB 2022b does allow for an overlay consisting of user-defined Lat/Long coordinates.
Mike D.
Mike D. le 29 Avr 2024
Brad, are you saying the patch command now allows color filled polygons on geoaxes, or maybe after creating a polyshape with geopolyshape?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by