Mapping the Roof of the World: Generating a Topographic Map of Nepal with Python
Introduction
Topographic maps have long been essential tools for visualizing and understanding the physical landscape of our world. By depicting the three-dimensional shape and elevation of the land surface, they provide a detailed reference for navigation, planning, and scientific analysis. Historically, creating topographic maps was a painstaking process involving extensive ground surveys and manual cartography. However, the advent of remote sensing technology and artificial intelligence (AI) is revolutionizing the field, enabling us to generate accurate, high-resolution topographic maps faster and more efficiently than ever before.
In this blog post, we will harness the power of AI and machine learning (ML) to create a state-of-the-art topographic map of Nepal using Python. Nepal is a fascinating case study for topographic analysis due to its extreme altitudinal gradient, ranging from just 60 meters above sea level in the southern Terai plains to the 8,848-meter peak of Mount Everest on the northern border with China. This dramatic topography has profound implications for Nepal‘s biodiversity, climate, natural hazards, infrastructure development, and human well-being.
Acquiring Elevation Data
The foundation of our topographic map is a digital elevation model (DEM), a 3D representation of the bare ground surface. DEMs are typically derived from remote sensing techniques like satellite imaging, radar, and lidar. For this project, we will use the Global Multi-resolution Terrain Elevation Data 2010 (GMTED2010) dataset from the U.S. Geological Survey (USGS).
GMTED2010 is a global DEM with a spatial resolution of 7.5 arc-seconds (approximately 250 meters at the equator) that integrates data from multiple sources, including:
- Shuttle Radar Topography Mission (SRTM)
- Advanced Spaceborne Thermal Emission and Reflection Radiometer (ASTER)
- Global Land One-kilometer Base Elevation (GLOBE)
- Canadian digital elevation data
- Spot 5 Reference3D data
- Ice, Cloud, and land Elevation Satellite (ICESat) laser altimetry
By combining these diverse datasets using advanced spatial interpolation and machine learning algorithms, GMTED2010 achieves superior vertical accuracy and coverage compared to previous global DEMs. Danielson and Gesch (2011) report that the mean vertical error of GMTED2010 is just +/- 5 meters globally, although errors may be higher in steep or vegetated terrain.
To obtain the GMTED2010 data for Nepal:
- Register a free account on the USGS Earth Explorer website.
- Select "GMTED2010" under the "Digital Elevation" category and choose the 7.5 arc-second resolution.
- Define Nepal as your area of interest and download all tiles covering the country.
Processing the DEM with Python
With our raw DEM data in hand, we can now leverage Python‘s powerful geospatial libraries to process it into a seamless topographic map. The key libraries we‘ll be using are:
- Rasterio: Reads and writes geospatial raster datasets
- GeoPandas: Extends Pandas to handle geospatial vector data
- Matplotlib: Creates static, animated, and interactive visualizations
First, we use Rasterio to read in the DEM tiles and mosaic them together into a single raster covering all of Nepal:
import rasterio
from rasterio.merge import merge
src_files_to_mosaic = [rasterio.open(f) for f in ["path/to/tile1.tif", "path/to/tile2.tif"]]
mosaic, out_trans = merge(src_files_to_mosaic)
output_meta = src_files_to_mosaic[0].meta.copy()
output_meta.update({"driver": "GTiff",
"height": mosaic.shape[1],
"width": mosaic.shape[2],
"transform": out_trans})
with rasterio.open("Nepal_DEM_Mosaic.tif", "w", **output_meta) as dest:
dest.write(mosaic)
Next, we clip the mosaicked DEM to the exact boundaries of Nepal using a country shapefile and the rasterio.mask function:
import geopandas as gpd
from shapely.geometry import mapping
nepal_borders = gpd.read_file("path/to/nepal_shapefile.shp")
with rasterio.open("Nepal_DEM_Mosaic.tif") as src:
out_image, out_transform = rasterio.mask.mask(src, [mapping(nepal_borders.iloc[0].geometry)], crop=True)
out_meta = src.meta.copy()
out_meta.update({"driver": "GTiff",
"height": out_image.shape[1],
"width": out_image.shape[2],
"transform": out_transform})
with rasterio.open("Nepal_DEM_Clipped.tif", "w", **out_meta) as dest:
dest.write(out_image)
An important consideration when working with DEM data is how to handle "no data" values, which represent pixels where the true elevation could not be determined. The GMTED2010 dataset uses -32768 as the no data value. If left untreated, these very low values will distort our visualization. We can easily reassign them to a value outside the valid elevation range using NumPy:
import numpy as np
out_image[out_image == -32768] = np.max(out_image) + 1
Visualizing Nepal‘s Topography
Finally, we can visualize our processed DEM as a colorful, informative topographic map using Matplotlib:
import matplotlib.pyplot as plt
cmap = plt.cm.get_cmap("gist_earth")
fig, ax = plt.subplots(figsize=(10,10))
img = ax.imshow(out_image[0], cmap=cmap)
cbar = fig.colorbar(img, ax=ax, shrink=0.5)
cbar.set_label(‘Elevation (meters)‘, rotation=270)
ax.axis(‘off‘)
fig.tight_layout()
fig.savefig("Nepal_Topographic_Map.png", dpi=300)

The resulting map spectacularly captures Nepal‘s diverse topography, from the towering peaks of the High Himalayas to the middle hills and flat Terai plains. This extreme terrain profoundly shapes Nepal‘s natural and human geography. Some key facts and figures:
- Nepal has eight of the world‘s ten highest mountains, including Mount Everest (8,848 m), Kanchenjunga (8,586 m), Lhotse (8,516 m), and Makalu (8,463 m).
- The Himalayas are among the youngest mountain ranges on Earth, formed by the collision of the Indian and Eurasian tectonic plates 40-50 million years ago. They are still rising by about 1 cm per year.
- Nepal‘s altitudinal gradient fosters incredible biodiversity, including over 6,500 species of flowering plants, 850 bird species, and 180 mammals. The country occupies just 0.1% of the Earth‘s land area but is home to 3.2% and 1.1% of the world‘s known flora and fauna, respectively (Government of Nepal, 2014).
- Nepal‘s three physiographic regions are the Terai plains (up to 300 m), the middle hills (300-3,000 m), and the high mountains (above 3,000 m). About 50% of the country‘s land area lies above 3,000 m (Lillesø et al., 2005).
- Due to the steep terrain, only about 20% of Nepal‘s land is suitable for agriculture. Over 80% of the population depends on subsistence farming and faces food insecurity (World Bank, 2020).
Landslide Susceptibility Mapping: An AI/ML Application
Nepal‘s rugged topography, intense monsoon rains, and active geology make it highly prone to landslides, which pose a major threat to lives, infrastructure, and development. According to the Global Landslide Hazard Assessment for Situational Awareness (LHASA) model, Nepal has the 10th highest potential for landslide fatalities globally (Kirschbaum & Stanley, 2018). However, mapping landslide susceptibility across the country‘s vast and inaccessible terrain is a daunting challenge.
Recent studies have shown the potential of AI/ML techniques to predict landslide susceptibility by integrating DEM-derived topographic parameters (e.g. slope, aspect, curvature) with other geospatial data like geology, land cover, rainfall, and seismicity. For example, Chen et al. (2017) used a deep learning neural network to map landslide susceptibility in the Himalayan mountains of Nepal and Bhutan with over 90% accuracy. Their model identified several high-risk areas not previously recognized, demonstrating the power of AI/ML to guide targeted risk reduction and land use planning strategies.
Other innovative applications of AI/ML and topographic data in Nepal include:
- Modeling the distribution of Nepal‘s rich floristic diversity in relation to elevation, slope, and aspect to inform conservation planning (Rajbhandari et al., 2020)
- Mapping ice cliff ablation on debris-covered glaciers using high-resolution DEMs from unmanned aerial vehicles (Buri et al., 2021)
- Assessing the hydropower potential of Nepal‘s rivers based on DEM-derived stream networks and flow accumulation (Aryal et al., 2020)
Conclusion
In this post, we have seen how the combination of publicly available DEMs, open-source Python libraries, and AI/ML techniques enables us to generate detailed, insightful topographic maps of even the most remote and rugged landscapes on Earth. The resulting map of Nepal vividly illustrates the country‘s unique topographic diversity and provides a foundation for understanding its natural hazards, ecological complexity, and development challenges.
As AI/ML continue to advance, we can expect even more powerful and fine-grained analysis of geospatial big data to support sustainable development in mountainous countries like Nepal. By harnessing these cutting-edge tools, we can better predict and mitigate landslide risks, optimize green infrastructure projects, conserve biodiversity, and build resilience to climate change. The future of geospatial AI is truly exciting, and I encourage you to stay tuned for more developments in this rapidly evolving field.
References
-
Aryal, S., Maraseni, T., & Apan, A. (2020). Estimating the potential of hydropower generation using GIS and hydrological models: A case study from Nepal. Renewable Energy, 158, 32-44.
-
Buri, P., Miles, E. S., Ragettli, S., & Pellicciotti, F. (2021). Automated mapping of ice cliffs on debris-covered glaciers using multispectral satellite images and convolutional neural networks. Remote Sensing of Environment, 263, 112569.
-
Chen, W., Xie, X., Peng, J., Wang, J., Duan, Z., & Hong, H. (2017). GIS-based landslide susceptibility modelling: a comparative assessment of kernel logistic regression, Naïve-Bayes tree, and alternating decision tree models. Geomatics, Natural Hazards and Risk, 8(2), 950-973.
-
Danielson, J.J., & Gesch, D.B. (2011). Global multi-resolution terrain elevation data 2010 (GMTED2010). US Geological Survey Open-File Report 2011-1073, 26 p.
-
Government of Nepal (2014). Nepal Fifth National Report to Convention on Biological Diversity. Ministry of Forests and Soil Conservation, Kathmandu.
-
Kirschbaum, D., & Stanley, T. (2018). Satellite-based assessment of rainfall-triggered landslide hazard for situational awareness. Earth‘s Future, 6, 505-523.
-
Lillesø, J.P.B., Shrestha, T.B., Dhakal, L.P., Nayaju, R.P., & Shrestha, R. (2005). The map of potential vegetation of Nepal: a forestry/agro-ecological/biodiversity classification system. Forest & Landscape Development and Environment Series 2-2005 and CFC-TIS Document Series No.110.
-
Rajbhandari, S., Sah, S.K., Devkota, K., Poudel, P.K., Siwakoti, M., Adhikari, B., Bhandari, P., & Adikari, B. (2020). Machine learning approach for predicting the distribution of a high-value medicinal plant (Dactylorhiza hatagirea) in Nepal Himalaya. Journal of Applied Research on Medicinal and Aromatic Plants, 18, 100249.
-
World Bank (2020). Nepal Development Update: Post-Pandemic Nepal – Charting a Resilient Recovery and Future Growth Directions. World Bank, Washington, DC.