python-3.x - 如何在正交图的边界绘制 Lon/Lat 值?
问题描述
我在cartopy中使用了一些南极洲轮廓的shapefile数据,这很好用。我可以用 shapefile 和一些更多的信息生成一个图。但我无法在图像的边界绘制经度和纬度信息。
我使用具有central_longitude 和central_latitude 的正交投影。
我还需要提一下,我对 cartopy 比较陌生。
我的代码:
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader
# 01
b01e01_lat = -73.86750000
b01e01_lon = -60.22694444
b01e02_lat = -73.89166667
b01e02_lon = -56.68500000
b01e03_lat = -74.87222222
b01e03_lon = -58.26805556
b01e04_lat = -74.85000000
b01e04_lon = -60.43083333
b01e05_lat = -73.86750001
b01e05_lon = -60.22694445
b01_lat = np.array([b01e01_lat,b01e02_lat,b01e03_lat,b01e04_lat, b01e01_lat, b01e05_lat])
b01_lon = np.array([b01e01_lon,b01e02_lon,b01e03_lon,b01e04_lon, b01e01_lon, b01e05_lon])
# 02
b02e01_lat = -73.94555556
b02e01_lon = -51.00055556
b02e02_lat = -74.22333333
b02e02_lon = -49.37000000
b02e03_lat = -74.87555556
b02e03_lon = -50.71888889
b02e04_lat = -74.87583333
b02e04_lon = -51.00055556
b02e05_lat = -73.94555557
b02e05_lon = -51.00055557
fname='Coastline_Antarctica_v02.shp'
#ax = plt.axes(projection=ccrs.SouthPolarStereo())
plt.figure()
ax = plt.axes(projection=ccrs.Orthographic(central_longitude=-41,
central_latitude=-71))
ax.set_extent([-85,-12,-75,-60], crs=ccrs.PlateCarree())
ax.add_geometries(Reader(fname).geometries(),ccrs.Orthographic(central_longitude=-0,
central_latitude=-90), color='grey')
ax.gridlines()
plt.plot(b01_lon,b01_lat, color='r', transform=ccrs.PlateCarree())
plt.plot(b02_lon,b02_lat, color='r', transform=ccrs.PlateCarree())
plt.show()
任何帮助表示赞赏!
解决方案
如果您运行代码来生成交互式绘图(%matplotlib notebook
在 jupyter notebook 上使用),您可以移动鼠标光标来读取您需要绘制标签的位置。
使用这种方法,我可以获得用于绘制 2 个样本标签的近似(经纬度)位置。绘制它们的代码如下:
ax.text(-80.6, -57.0, '{0}\N{DEGREE SIGN} S '.format(57), va='center', ha='right',
transform=ccrs.PlateCarree())
ax.text(-75.15, -56.0, '{0}\N{DEGREE SIGN} W '.format(75), va='bottom', ha='center',
transform=ccrs.PlateCarree())
输出图将如下所示:
推荐阅读
- math - 给定曲线该部分下的面积,有没有办法在 TI-84 Plus CE 上找到未知积分界
- angular - 图片未在 Angular 11 中加载
- notepad++ - 将一个句子的位置切换到另一个句子而不更改记事本++上的特定单词位置
- css - CSS:按钮边框的背景过滤器(潜在的解决方案?)
- php - 增加 Cookie 发送的每个请求的数量
- single-page-application - 经典体验下Auth0用户会话持久化
- node.js - 将 setInterval 与 socket.write 一起使用
- geocoding - 为什么 Tesco 为这个 here-api 查询返回 T-mobile?
- nginx - Nginx 将路径重定向到其他路径
- javascript - 使用 console.log 时,Typescript 将数组渲染为 [object Object]