假设我有一张带有行星圆柱状地图的图像,比如这些之一:
http://www.johnstonsarchive.net/spaceart/cylmaps.html
我想在一个三维球体上绘制它,以恢复行星的原始图像。有没有一种使用Python包(如matplotlib,mayavi,basemap或类似工具)的方法可以实现这一目标?
假设我有一张带有行星圆柱状地图的图像,比如这些之一:
http://www.johnstonsarchive.net/spaceart/cylmaps.html
我想在一个三维球体上绘制它,以恢复行星的原始图像。更新:由于basemap已过时,因此这是使用Cartopy的新版本。以下是原始答案。
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
img = plt.imread("/tmp/venuscyl4.tif")
plt.figure(figsize=(3, 3))
ax = plt.axes(projection=ccrs.Orthographic(-10, 45))
ax.gridlines(color='black', linestyle='dotted')
ax.imshow(img, origin="upper", extent=(-180, 180, -90, 90),
transform=ccrs.PlateCarree()) # Important
plt.show()
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
# set up orthographic map projection with
# perspective of satellite looking down at 50N, 100W.
# use low resolution coastlines.
# don't plot features that are smaller than 1000 square km.
bmap = Basemap(projection='ortho', lat_0 = 50, lon_0 = -100,
resolution = 'l', area_thresh = 1000.)
# plot surface
bmap.warpimage(image='venuscyl4.jpg')
# draw the edge of the map projection region (the projection limb)
bmap.drawmapboundary()
# draw lat/lon grid lines every 30 degrees.
bmap.drawmeridians(np.arange(0, 360, 30))
bmap.drawparallels(np.arange(-90, 90, 30))
plt.show()
产生以下输出:
bluemarble
函数调用了warpimage
:https://github.com/matplotlib/basemap/blob/master/lib/mpl_toolkits/basemap/__init__.py#L4016这可能正是我想要的。我稍后会尝试一下,谢谢。 - astrojuanlu