使用圆锥投影时,在Python的Basemap中沿一个恒定纬度绘制一条直线

2024-03-29 09:41:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在一个basemap实例上画一条连接两个等纬度的点,使用圆锥地图投影(即纬度不是直线)。在

不管我是使用m.drawgreatcircle还是m.plot,结果都是一条直的(-我想…?)两点之间的线,而不是沿着恒定纬度的线。有人知道怎么解决这个问题吗?下面是一些示例代码和生成的图像。我非常希望这条黄色虚线沿着55N线运行。在

import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

#set up the map
m = Basemap(resolution='l',area_thresh=1000.,projection='lcc',\
        lat_1=50.,lat_2=60,lat_0=57.5,lon_0=-92.5,\
        width=6000000,height=4500000)


#add some basic map features
m.drawmeridians(np.arange(-155,-5,10),\
       labels=[0,0,0,1],fontsize=8,linewidth=0.5)
m.drawparallels(np.arange(30,85,5),\
       labels=[1,0,0,0],fontsize=8,linewidth=0.5)
m.drawcoastlines(linewidth=0.5)
m.drawcountries(linewidth=1)
m.drawstates(linewidth=0.3)

#plot some topography data
m.etopo()

#draw a line between two points of the same latitude
m.drawgreatcircle(-120,55,-65,55,linewidth=1.5,\
       color='yellow',linestyle='--')

I want the yellow dashed line to run along the line of latitude!

抱歉,如果我错过了一些非常简单的东西。。。!在


Tags: theimportmaplabelsplotnpsomebasemap
1条回答
网友
1楼 · 发布于 2024-03-29 09:41:38

drawgreatcicle显然在lcc投影映射上工作不正常。在

您总是可以自己创建一条线,而不是依赖于这个helper函数。为此,沿着这条线创建坐标,投影它们并调用plot。在

lon = np.linspace(-120,-65)
lat = np.linspace(55,55)
x,y = m(lon,lat)
m.plot(x,y, linewidth=1.5, color='yellow',linestyle=' ')

enter image description here

相关问题 更多 >