The invention of railways less than 200 years ago coincided with the colonization by Europeans of vast swathes of the world.