Terrain & elevation
Working with DEMs: slope, aspect, hillshade, contours, profiles and drainage.
Everything in this topic is derived from one array of elevations, and every derivative — slope, aspect, hillshade, curvature, flow direction — is computed from a cell and its immediate neighbours. That is why the cell size is not a detail: the same hillside measured on a 1 m DEM and a 30 m DEM gives genuinely different slopes, and neither is wrong.
The other recurring issue is units. A DEM in metres on a grid in degrees produces slopes that are absurd by a factor of about 10⁵, and the calculation completes without complaint. Vertical datums add a second axis of the same problem: elevations above an ellipsoid and above a geoid differ by tens of metres.
The pages below cover what each derivative means, how to compute it correctly, and the specific ways a terrain analysis comes out wrong — most often because a CRS, a unit or a resolution was not what the function assumed.
🧭 Start with the concepts
The ideas the how-to guides below assume you already have.
- Digital Elevation Models Explained: DEM, DSM and DTM
- Vertical Datums Explained: Why Your Elevations Are Off
- Slope and Aspect Explained: How They Are Computed from a Grid
- DSM, DTM and CHM from LiDAR: How Each Surface Is Derived
- DEM Hydrology Explained: From Elevation to Where Water Goes
- Flow Direction Explained: D8, D-Infinity and MFD Compared
Show every concept in this topic
- Pour Points Explained: Why Watershed Delineation Needs a Snapped Outlet
- How DEM Resolution and Source Change a Drainage Network
- Height Above Nearest Drainage Explained: A Quick Flood Proxy
- SAR geometry explained: layover, foreshortening, shadow and look direction
- InSAR explained: measuring millimetres of ground motion from phase
- Landslide susceptibility explained: what the map is and is not
- Terrain Shading and the Horizon Explained
⚙️ Then do the task
Step-by-step walkthroughs with code you can copy and adapt.
- How to Calculate Slope and Aspect from a DEM in Python
- How to Make a Hillshade from a DEM in Python
- How to Generate Contour Lines from a DEM in Python
- How to Extract an Elevation Profile Along a Line in Python
- How to Fill Sinks and Derive Flow Direction from a DEM
- How to Calculate a Viewshed in Python
Show every how-to guide in this topic
- How to Create a DTM from LiDAR Ground Points in Python
- How to Create a Canopy Height Model from LiDAR
- How to Measure Building Heights from LiDAR in Python
- How to Build a TIN and Interpolate Elevations
- How to Run a Weighted Site Suitability Analysis in Python
- How to Condition a DEM for Hydrology: Breaching or Filling
- How to Calculate Flow Accumulation from a DEM in Python
- How to Delineate a Watershed from a Pour Point in Python
- How to Extract a Stream Network from a DEM
- How to Calculate Strahler Stream Order in Python
- How to Split a Catchment into Sub-basins at Many Outlets
- How to Summarise Catchment Attributes: Area, Slope and Land Cover
- How to Calculate Height Above Nearest Drainage (HAND) in Python
- How to Burn a Known River Network into a DEM
- How to test whether a window can see a landmark
- How to map coastal inundation from a DEM in Python
- How to build a landslide susceptibility index in Python
- How to Find the Optimal Tilt and Orientation for Solar Panels
- How to Compute a Horizon Profile from a DEM in Python
- How to Compute Glacier Hypsometry from a DEM in Python
- How to Find the Snow Line Elevation in Python
- How to Get the Elevation of Coordinates in Python
🔧 When it breaks
The errors this topic produces, with the cause explained rather than just the command.
- Slope Values Are Wrong or Absurdly Steep
- Hillshade Looks Flat, Washed Out or Inverted
- Contours Come Out Jagged or Full of Tiny Rings
- My LiDAR DTM Has Holes, Spikes or Terraces
- Fixing a Watershed That Comes Out as a Few Pixels
- Fixing Streams That Run in Straight Parallel Lines Across Flat Ground
Show every fix in this topic
- Fixing Flow Accumulation That Is All Zeros, NoData or Stops at the Edge
- Fixing Streams That Stop at Roads, Bridges and Embankments
- Fixing Catchment Areas That Are Wrong on a Latitude–Longitude DEM
- Extruded buildings float above or sink into the ground
- An inundation map floods inland areas that cannot flood
- A SAR image looks stretched or smeared in mountains
Learning paths through this topic
A curated route rather than a list — the guides in the order that builds on itself.
Related topics
Subjects that keep coming up alongside this one, most overlap first.