matplotlib / matplotlib/basemap
[Bug]: Basemap drawgreatcircle generating gaps in Mercator projection
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 817
- 派生
- 395
- PR 合并指标
- 30 天内没有已合并 PR
描述
### 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

### Expected outcome

### 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
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 __init__.py 中 max_dist 计算附近的 drawgreatcircle path-cut 逻辑开始,然后使用 Mercator 投影运行 Python 复现。调查当前距离阈值为何会在高纬度地区产生间隙;完成的标准是两个大圆路径能够连续渲染,同时不会引入错误的 wraparound 连接。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- matplotlib, numpy, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100