London Necropolis Railway

From the Wikipedia page

The London Necropolis Railway was a railway line opened in November 1854 by the London Necropolis Company (LNC), to carry corpses and mourners between London and the LNC's newly opened Brookwood Cemetery 23 miles (37 km) southwest of London in Brookwood, Surrey. At the time the largest cemetery in the world, Brookwood Cemetery was designed to be large enough to accommodate all the deaths in London for centuries to come, and the LNC hoped to gain a monopoly on London's burial industry. The cemetery had intentionally been built far enough from London so as never to be affected by urban growth and was dependent on the recently invented railway to connect it to the city.

The railway mostly ran along the existing tracks of the London and South Western Railway (LSWR) but had its own branches from the main line at both London and Brookwood. Trains carried coffins and passengers from a dedicated station in Waterloo, London, onto the LSWR tracks. On reaching the cemetery, the trains reversed down a dedicated branch line to two stations in the cemetery, one for the burial of Anglicans and one for Nonconformists (non-Anglicans) or those who did not want a Church of England funeral. The station waiting rooms and the compartments of the train, both for living and for dead passengers, were partitioned by both religion and class to prevent both mourners and cadavers from different social backgrounds from mixing. As well as the regular funeral traffic, the London Necropolis Railway was used to transport large numbers of exhumed bodies during the mass removal of a number of London graveyards to Brookwood.