Effacer les filtres
Effacer les filtres

Mapping toolkit: problems plotting near the pole

4 vues (au cours des 30 derniers jours)
James
James le 24 Jan 2024
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');

Réponses (1)

Kevin Holly
Kevin Holly le 25 Avr 2024
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');

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by