matplotlib / matplotlib/basemap

[Bug]: Basemap drawgreatcircle generating gaps in Mercator projection

Ouverte
#606 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Python
Étoiles
817
Forks
395
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

### Bug summary

I see an issue where drawgreatcircle() produces paths with gaps in with the Mercator projection.

I can see from web searches that others have seen the same issue and suggestions point to gathering the path using computations with other projections.

### Code for reproduction

```Python
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

# setup mercator map projection.
m = Basemap(llcrnrlon=-180.,llcrnrlat=-65.,\
urcrnrlon=180.,urcrnrlat=85.,\
projection='merc',\
lat_0=40.,lon_0=-20.,lat_ts=20.)
m.drawcoastlines()
m.fillcontinents()

# AMS
amslat = np.float64(52.309)
amslon = np.float64(4.764)
# Seattle
sealat = np.float64(47.449)
sealon = np.float64(-122.309)
# Helsinki
hellat = np.float64(60.320)
hellon = np.float64(24.956)

m.drawgreatcircle(amslon,amslat,sealon,sealat,linewidth=2,color='b')
m.drawgreatcircle(sealon,sealat,hellon,hellat,linewidth=2,color='b')

# draw parallels
m.drawparallels(np.arange(-60,65,20))
# draw meridians
m.drawmeridians(np.arange(-180,180,30))
plt.show()
```

### Actual outcome

![Gaps_times2](https://github.com/user-attachments/assets/cb6a236e-f4d2-4626-972e-9bfe9a3ab4ab)

### Expected outcome

![Gaps_times5](https://github.com/user-attachments/assets/97d25ddf-6005-4fe1-afa9-ff01db118f9c)

### Additional information

I don't understand the basemap calculations and how projections enter into it but I can recover the correct output if I change the test for cuts in the source code by making max_dist much larger...

```
diff -c __init*py.orig **init*py
*** __init__.py.orig Mon Aug 26 08:40:10 2024
--- __init__.py Mon Aug 26 09:28:34 2024
***************
*** 2901,2907 ****
p = _p[0].get_path()

# since we know the difference between any two points, we can use this to find wrap arounds on the plot
! max_dist = 1000*del_s*2

# calculate distances and compare with max allowable distance
dists = np.abs(np.diff(p.vertices[:,0]))
--- 2901,2907 ----
p = _p[0].get_path()

# since we know the difference between any two points, we can use this to find wrap arounds on the plot
! max_dist = 1000*del_s*5

# calculate distances and compare with max allowable distance
dists = np.abs(np.diff(p.vertices[:,0]))
```
This is what I did to generate the output in the expected result box.
It would be helpful if the defaults did allow great circle paths into high lattitudes.

### Operating system

Windows 10

### Matplotlib Version

3.8.4

### Matplotlib Backend

3.8.4

### Python version

3.12.2

### Jupyter version

_No response_

### Installation

conda

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez dans __init__.py, autour de la logique de path-cut de drawgreatcircle près du calcul de max_dist, puis exécutez la reproduction Python avec la projection de Mercator. Étudiez pourquoi le seuil de distance actuel crée des discontinuités aux hautes latitudes ; le travail est terminé lorsque les deux tracés de grand cercle sont rendus de manière continue sans introduire de connexions wraparound incorrectes.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
matplotlib, numpy, python
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.