【发布时间】:2021-10-29 04:23:57
【问题描述】:
在给定像素坐标的情况下,我想获取数据点的纬度和经度。我对matplotlib转换很困惑,但我想解决问题的关键就在这里。
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
import cartopy.feature as cfeature
MIN_LAT = 5
MAX_LAT = 70
MIN_LON = -100
MAX_LON = 23
# Map
fig = plt.figure(figsize=(12,7))
proj = ccrs.PlateCarree(central_longitude=0)
ax=plt.axes(projection=proj)
ax.add_feature(cfeature.LAND, color='lightgray')
ax.add_feature(cfeature.OCEAN)
# Select area
ax.set_extent([MIN_LON, MAX_LON, MIN_LAT, MAX_LAT], crs=proj)
fig.canvas.draw()
例如,给定像素坐标 (0, 0)(matplotlib 中的左下角),我希望返回地理坐标 (MIN_LON, MIN_LAT)。
【问题讨论】:
标签: python matplotlib coordinates cartopy geography