如何绘制从旋转坐标

时间:2018-04-27 17:52:18

标签: python geospatial matplotlib-basemap

我的域的四个角的坐标是旋转坐标。 这些是 rlons:-25.6,32.48,-25.6,32.48

rlats:-27.6,-27.6,26.08,26.08

旋转的北极是 lon -170,lat 40

首先,我必须将角点从旋转坐标转换为地理坐标。

转换后,实际的地理坐标为

lons:-13.7893,39.6672,82.6967,-54.64,-13.7893

拉特:18.3262,15.9548,59.6559,64.5671,18.3262

然后我想在底图中绘制角点。但是我的代码没有做出准确的界限。准确的边界应该是弯曲的,而不是在顶部和底部的直线。

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

x_big = [-13.7893,39.6672,82.6967,-54.64,-13.7893]
y_big = [18.3262,15.9548,59.6559,64.5671,18.3262]

fig=plt.Figure()
ax = fig.add_subplot(1, 1, 1)
map = Basemap(projection='cyl', resolution = 'i', llcrnrlon=-60, llcrnrlat=5,urcrnrlon=90, urcrnrlat=70)
map.drawcoastlines()
map.drawcountries()
map.bluemarble()
map.plot(x_big, y_big, color='r', lw=5)
map.drawparallels(np.arange(5.,75.,15.),labels=[1,0,0,0])
map.drawmeridians(np.arange(-60.,90.,30.),labels=[0,0,0,1])
plt.show()

当我运行它时,它会生成一个右角的地图,但不知何故,连接角的线是直线,这是不准确的。它应该如附图所示:enter image description here

1 个答案:

答案 0 :(得分:1)

您需要使用.drawgreatcircle()方法而不是简单的plot()。这是工作代码。

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

# these coordinates for points far apart
x_big = [-13.7893, 39.6672, 82.6967, -54.64, -13.7893]  # lon
y_big = [18.3262, 15.9548, 59.6559, 64.5671, 18.3262]   # lat

fig = plt.Figure()
ax = fig.add_subplot(1, 1, 1)
map = Basemap(projection='cyl', resolution = 'i', llcrnrlon=-60, \
              llcrnrlat=5, urcrnrlon=90, urcrnrlat=82)
map.drawcoastlines()
map.drawcountries()
map.bluemarble()
map.plot(x_big, y_big, color='red', lw=1)

# plot line of great circles
map.drawgreatcircle(x_big[0], y_big[0], x_big[1], y_big[1], del_s=500, lw=2, color="y")
map.drawgreatcircle(x_big[1], y_big[1], x_big[2], y_big[2], del_s=500, lw=2, color="y")
map.drawgreatcircle(x_big[2], y_big[2], x_big[3], y_big[3], del_s=500, lw=2, color="y")
map.drawgreatcircle(x_big[3], y_big[3], x_big[0], y_big[0], del_s=500, lw=2, color="y")

map.drawparallels(np.arange(5., 75., 15.), labels=[1,0,0,0])
map.drawmeridians(np.arange(-60., 90., 30.), labels=[0,0,0,1])
plt.show()

结果情节:

enter image description here