我试图绘制从科罗拉多州丹佛市可见的天空区域,并在Map投影上将该区域显示为阴影“圆”。
我希望在Map上有一个扭曲的圆圈(因为Map投影),以丹佛为中心。当我尝试绘制具有填充的形状圆时,它似乎正确居中,但它沿着纬度分裂,如图所示。我不知道它为什么会这样做,以及如何纠正它。期望的结果是曲线上方的区域(所有北美和俄罗斯上方的海洋)被着色为红色。
import numpy as np
import cartopy.geodesic as cgeod
import cartopy.crs as crs
import cartopy.feature as cfeature
import shapely
import matplotlib.pyplot as plt
# SET CONSTANTS
RE = 6371008.8 # meters, WGS84 Sphere
h = 35786000.0 # meters, GEO
def arc_dist_to_FOV(h, ah):
a = (np.pi/180)*(90 + ah) # radians
b = np.arcsin(RE * np.sin(a)/(RE + h)) # radians
g = np.pi - a - b # radians
d = (180/np.pi)*g*RE
return d
cm = 0
proj = crs.PlateCarree(central_longitude=cm)
fig = plt.figure(figsize=(10,8))
ax = fig.add_subplot(1,1,1, projection=proj)
ax.set_global()
ax.add_feature(cfeature.COASTLINE, edgecolor='black')
ax.add_feature(cfeature.BORDERS, edgecolor='black')
ax.add_feature(cfeature.STATES, edgecolor='black')
ax.stock_img()
# ax.background_img(name='BM', resolution='high')
ax.gridlines(draw_labels=True, crs=proj)
lat, lon = 39.7392, -104.985
plt.scatter(x=lon, y=lat, color='blue', s=10, transform=proj)
# COMPUTE FOV
ah = 20 # degrees above horizon
dFOV = arc_dist_to_FOV(h, ah)
site_lat = lat
site_lon = lon
# ADD SHAPES TO MAP
circle_points = cgeod.Geodesic().circle(lon=site_lon, lat=site_lat, radius=dFOV, n_samples=1000, endpoint=False)
geom = shapely.geometry.Polygon(circle_points)
ax.add_geometries((geom,), crs=proj, alpha=0.5, facecolor='red', edgecolor='black', linewidth=1)
# must save BEFORE show cmd
# plt.savefig('name.png', bbox_inches='tight', dpi=300)
plt.show()```
1条答案
按热度按时间kxkpmulp1#
对于在任何投影上绘制圆(的投影),可以使用
.tissot()
方法。这大大简化了在Map上画圆圈的过程。下图中的大圆(投影)使用了这行代码:
在正交投影视图中,图将类似于下图: