[英]Cartopy central_longitude causes lat/lon co-ordinates to be plot in incorrect place
我正在繪制帶有緯度/經度坐標的飛行軌跡。 以下代碼生成准確的緯度/經度圖,但飛行路徑被切斷。
fig = plt.figure(fig size(16,8))
ax = plot.subplot(1,1,1, projection = cars.PlateCarree())
ax.coastlines()
#Add gridlines and customise
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth = 2)
gl.xlabels_top = False
gl.ylabels_left = False
ax.add_feature(cfeature.OCEAN)
ax.add_feature(feature.LAND)
ax.set_ylim(-90, 60)
#Plot lon/lat points as scatter points
im.ax.scatter(lon, lat, s = 20)
這顯示了未應用 central_longitude 的成功代碼的圖像 - 這是正確的飛行路徑軌跡:
我希望飛行軌跡位於情節的中間 - 而不是在情節的邊緣被切斷。 我在定義投影時插入“central_longitude”,如下所示:
fig = plt.figure(fig size(16,8))
ax = plot.subplot(1,1,1, projection = cars.PlateCarree(central_longitude = 40))
ax.coastlines()
#Add gridlines and customise
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth = 2)
gl.xlabels_top = False
gl.ylabels_left = False
ax.add_feature(cfeature.OCEAN)
ax.add_feature(feature.LAND)
ax.set_ylim(-90, 60)
#Plot lon/lat points as scatter points
im.ax.scatter(lon, lat, s = 20)
這會導致飛行路徑的位置不正確,如下圖所示。 地圖已相應移動,但飛行路徑保持不變。 我應該如何解決這個問題?
應用了“central_longitude = 40”的飛行路徑 - 地圖已移動,但飛行軌跡仍在同一個地方:
由於您的軸與您的數據具有不同的投影,因此您需要告訴 cartopy 從特定投影轉換數據:
im.ax.scatter(lon, lat, s=20, transform=ccrs.PlateCarree())
有關更多信息,請參閱了解投影和變換關鍵字的 cartopy 文檔
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.