Model trains in one form or another have been around for well over 100 years, and the work and detail that goes into some of these sets is really incredible. Given this attention to detail and the inherent electrical nature of many of these sets, it only makes sense to interface one with a computer, like the small and powerful Raspberry Pi.
You could interface a ‘Pi by running individual wires to each of your switch motors and lights, but this would obviously become complicated quickly, leading to potential setup frustrations and maintenance issues. Another great option, available here on Tindie, is the PiRyte interface board. The main interface board in this kit stacks on top of a Raspberry Pi computer, allowing it to communicate to remote modules via CAT5 Cables, rather than individual wires. This should simplify things greatly, and allow one to control tracks or lights with a relatively simple setup.
The video below gives an introduction to the system using a yard panel as an interface. As the video points out though, given the capability of the Raspberry Pi, this type of interface is only a small part of what it could do in this situation. For that matter, it would seem a system like this could have a huge number of applications outside of model train control, where someone simply wants a good way to wire inputs and outputs remotely