Mapping toolkit: problems plotting near the pole

6 ビュー (過去 30 日間)
James
James 2024 年 1 月 24 日
回答済み: Kevin Holly 2024 年 4 月 25 日
I'm using the mapping toolkit to display some data near the north poles, and I noticed that many of MATLAB's mapping functions break down near the poles.
As a demonstration, consider patchm. If the polygon goes over the north pole, it will fill outside of the polygon, rather than inside of the polygon. Here's an example where you can see that patchm correctly fills in Antarctica when it's at the south pole, but fills outside of Antarctica if Antarctica is at the north pole.
The issue is very noticeable for patchm, but I've also noticed it for other functions (e.g., isinterior). I can implement improvised solutions to mitigate these things—like rotating the reference frame to do the calculations away from the poles—but I'd love if someone has a simpler solution.
load coastlines
figure(1);clf;
subplot(1,2,1); % Antarctica on the south pole
axesm sinusoid; framem; axis tight;
patchm(coastlat,coastlon,'b');
subplot(1,2,2); % Antarctica on the north pole (by flipping the latitude)
axesm sinusoid; framem; axis tight;
patchm(-coastlat,coastlon,'b');

回答 (1 件)

Kevin Holly
Kevin Holly 2024 年 4 月 25 日
James,
I reported the issue and obtained the following workaround:
load coastlines
% Invert the orientation of the line demarcating Antarctica’s coast
antarcticaLat = coastlat(1:612);
antarcticaLon = coastlon(1:612);
[newAntarcticaLon,newAntarcticaLat] = poly2ccw(antarcticaLon,antarcticaLat);
newcoastlat = [newAntarcticaLat; coastlat(613:end)];
newcoastlon = [newAntarcticaLon; coastlon(613:end)];
figure(1);clf;
subplot(1,2,1); % Antarctica on the south pole
axesm sinusoid; framem; axis tight;
patchm(coastlat,coastlon,'b');
subplot(1,2,2); % Antarctica on the north pole (by flipping the latitude)
axesm sinusoid; framem; axis tight;
patchm(-newcoastlat,newcoastlon,'b');

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by