Overlay polygon on geographic axes

52 visualizaciones (últimos 30 días)
Caroline Nowlan
Caroline Nowlan el 29 de Oct. de 2019
Comentada: Brad Onstott el 11 de Feb. de 2023
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.

Respuesta aceptada

Subhadeep Koley
Subhadeep Koley el 1 de Nov. de 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 comentarios
Caroline Nowlan
Caroline Nowlan el 1 de Nov. de 2019
Works perfectly. Thanks!
Evan Bates
Evan Bates el 6 de En. de 2021
Does not work with appdesigner.

Iniciar sesión para comentar.

Más respuestas (1)

Mike D.
Mike D. el 21 de Feb. de 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?
  3 comentarios
Mike D.
Mike D. el 19 de Feb. de 2021
Notice he is creating a new ax2 = axes overtop of the geoaxes, and then setting its limits to be axis([0 1 0 1]); So the coordinates are effectively normalized to the width and height (0 to 1).
This is more of a work-around by creating another axes overtop and making its axes labels invisible. Hopefully a future version of Matlab allows the geoaxes to create a patch on the geoaxes.
Brad Onstott
Brad Onstott el 11 de Feb. de 2023
Mike D: Good call! MATLAB 2022b does allow for an overlay consisting of user-defined Lat/Long coordinates.

Iniciar sesión para comentar.

Categorías

Más información sobre Geographic Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by