![geoPatch.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/245965/geoPatch.png)
Overlay polygon on geographic axes
조회 수: 43 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Subhadeep Koley
2019년 11월 1일
% 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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/245965/geoPatch.png)
댓글 수: 3
Kurt
2024년 12월 18일
This may work, but the patch has its own axis, and is not bound to the geoaxes object gx. You can grab it and move it around, independent of the background. They just happen to share the same frame, is all. Is there a way to bind these two objects so the patch won't move?
추가 답변 (1개)
Mike D.
2020년 2월 21일
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
Brad Onstott
2023년 2월 11일
Mike D: Good call! MATLAB 2022b does allow for an overlay consisting of user-defined Lat/Long coordinates.
Mike D.
2024년 4월 29일
Brad, are you saying the patch command now allows color filled polygons on geoaxes, or maybe after creating a polyshape with geopolyshape?
참고 항목
카테고리
Help Center 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!