日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python用cartopy包画地图_python – 使用Cartopy在地图上显示图像时的投影问题

發布時間:2024/1/8 python 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python用cartopy包画地图_python – 使用Cartopy在地图上显示图像时的投影问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我有一些我想用Cartopy顯示的衛星圖像數據.我已成功按照圖像示例詳細介紹了here.導致此代碼:

import numpy as np

import matplotlib.pyplot as plt

import cartopy.crs as ccrs

fig = plt.figure(figsize=(12,12))

img_extent = (-77,-59,9,26)

ax = plt.axes(projection=ccrs.PlateCarree())

# image data coming from server,code not shown

ax.imshow(img,origin='upper',extent=img_extent)

ax.set_xmargin(0.05)

ax.set_ymargin(0.10)

# mark a known place to help us geo-locate ourselves

ax.plot(-117.1625,32.715,'bo',markersize=7)

ax.text(-117,33,'San Diego')

ax.coastlines()

ax.gridlines()

plt.show()

此代碼生成以下圖像

我的問題是衛星圖像數據不在PlateCarree投影中,而是墨卡托投影.

但是當我得到軸對象時

ax = plt.axes(projection=ccrs.Mercator())

我失去了海岸線.

我看到了here報告的問題.但是

ax.set_global()

得到這張圖片的結果:

數據不存在,圣地亞哥位置錯誤.緯度/經度范圍也發生了變化.我究竟做錯了什么?

發布討論更新

主要問題是我沒有使用transform_points方法在目標投影中正確指定圖像范圍.我還必須具體說明菲爾建議的imshow方法中的坐標參考系統.這是正確的代碼:

import numpy as np

import matplotlib.pyplot as plt

import cartopy.crs as ccrs

proj = ccrs.Mercator()

fig = plt.figure(figsize=(12,12))

extents = proj.transform_points(ccrs.Geodetic(),np.array([-77,-59]),np.array([9,26]))

img_extents = (extents[0][0],extents[1][0],extents[0][6],extents[1][7] )

ax = plt.axes(projection=proj)

# image data coming from server,extent=img_extents,transform=proj)

ax.set_xmargin(0.05)

ax.set_ymargin(0.10)

# mark a known place to help us geo-locate ourselves

ax.plot(-117.1625,markersize=7,transform=ccrs.Geodetic())

ax.text(-117,'San Diego',transform=ccrs.Geodetic())

ax.coastlines()

ax.gridlines()

plt.show()

導致這個正確地理投影的衛星圖像:

總結

以上是生活随笔為你收集整理的python用cartopy包画地图_python – 使用Cartopy在地图上显示图像时的投影问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。