Digital elevation models (DEMs), which can provide an accurate description of planetary surface elevation changes, play an important role in scientific tasks such as long-distance path planning, terrain analysis, and planetary surface reconstruction. However, generating high-precision planetary DEMs currently relies on expensive equipment together with complex remote sensing technology, thus increasing the cost and cycle of the task. Therefore, it is crucial to develop a cost-effective technology that can produce high-quality DEMs on the surfaces of planets. In this work, we propose a global attention-based DEM generation network (GADEM) to convert satellite imagery into DEMs. The network uses the global attention mechanism (GAM) together with a multi-order gradient loss function during training to recover precise terrain. The experimental analysis on lunar and Martian datasets not only demonstrated the effectiveness and accuracy of GADEM in bright regions, but also showed its promising reconstruction ability in shadowed regions.