Earth Elevation ContoursΒΆ

../../_images/earth_elev_contours1.png

A custom colormap, hiTerrain, was constructed from the last 67% of the Matplotlib colormap gist_earth using the color map utilities function section_cmap.

../../_images/hiterrain_cmap.png

This cmap was then used to eliminate the blue color since only land mass is shown in the contours.

from matplotlib import pyplot as plt
from matplotlib import cm
import s3dlib.surface as s3d
import s3dlib.cmap_utilities as cmu

#.. Earth Elevation Contours

def radius(xyz) :
    rtp = s3d.SphericalSurface.coor_convert(xyz,False)
    return rtp[0]

cmu.section_cmap('gist_earth',0.33,1.0,'hiTerrain')

# 2. Setup and map surfaces .........................................
rez = 6

earth = s3d.SphericalSurface(rez,color='k')
earth.map_geom_from_image('data/elevation.png',0.07)

elev = earth.contourLineSet(8,coor='s')
elev.map_cmap_from_op( radius, cmap='hiTerrain' ).fade()
elev.set_linewidth(0.8)

# 3. Construct figure, add surfaces, and plot ......................

fig = plt.figure(figsize=plt.figaspect(1), facecolor='black' )
fig.text(0.02,0.02,str(elev), ha='left', va='bottom',
        fontsize='smaller', color='white')
ax = plt.axes(projection='3d')
ax.set_title('Elevation Contours',color='w')
minmax = (-0.85,0.85)
ax.set(xlim=minmax, ylim=minmax, zlim=minmax)
ax.set_facecolor('black')
ax.set_axis_off()
ax.view_init(25,-150)

ax.add_collection3d(elev)

fig.tight_layout(pad=0)
plt.show()