Move DEM processing to a separate function.