2017-02-10 28 views
0

我試圖從北極沿着素數子午線(經度= 0)放置藍色點,而是看到沿着日期線(經度= 180)的點。 代碼:經度關閉180度與cartopy Orthographic和RotatedPole

#!/usr/bin/env python 
import matplotlib.pyplot as plt 
import cartopy.crs as ccrs 
Lon = 0 
ax = plt.axes(projection=ccrs.Orthographic(central_latitude=70, 
              central_longitude=Lon)) 
ax.set_global() 
vector_crs = ccrs.RotatedPole(pole_latitude=90, pole_longitude=Lon) 
ax.plot([Lon, Lon, Lon, Lon, Lon, Lon], # longitude 
     [ 90, 80, 70, 60, 50, 40], # latitude 
     'bo', markersize=5, transform=vector_crs) 
ax.stock_img() 
plt.show() 

enter image description here

可能是一些相關的變換,但我還沒有想出什麼。 Cartopy版本0.14.2,Python 3.6。

回答

2

我認爲這個問題是來自變換,您已經定義的投影:

ax = plt.axes(projection=vector_crs) 
ax.coastlines() 
plt.show() 

transform used as plot projection

注意,這個簡單的海岸線在變換投影看起來像一個長方情節繪製中心經度爲180 °。考慮到這一點,讓我們來看看爲了也儘量簡化你繪製到地圖上用長方投影的陰謀策劃你的樣本數據點:

ax = plt.axes(projection=ccrs.PlateCarree()) 
ax.plot([Lon, Lon, Lon, Lon, Lon, Lon], 
     [ 90, 80, 70, 60, 50, 40], 
     'bo', markersize=5, transform=vector_crs) 
ax.stock_img() 
plt.show() 

transform onto PlateCarree projection

由於用你的例子,這些點不會出現在我們預期的地方。最後,讓我們嘗試使用長方投影爲他們繪製到一個正射時,變換你的觀點:

ax = plt.axes(projection=ccrs.Orthographic(central_latitude=70, 
              central_longitude=Lon)) 
ax.set_global() 
ax.plot([Lon, Lon, Lon, Lon, Lon, Lon], 
     [ 90, 80, 70, 60, 50, 40], 
     'bo', markersize=5, transform=ccrs.PlateCarree()) 
ax.stock_img() 
plt.show() 

PlateCarree transform onto Orthographic plot

這似乎提供更多您所尋找的情節。

+0

感謝您的詳細解答。我還沒有掌握預測和變換之間的關係,但現在應該有足夠的準備將它們拼湊在一起。 – AlDanial

+0

很高興這有幫助!讓我看看我是否也可以用'投影'和'變形'......當創建一個座標軸時使用的「投影」kwarg定義了一個座標圖的外觀:上面的Plate Carree座標圖與正交圖非常不同。繪製數據時使用的「轉換」kwarg定義了描述數據位置如何映射到地球表面的座標參照系。然後,「變換」定義數據必須如何轉換才能在地塊上正確定位。 – DPeterK