Grainger was born at Gogar Green near
Ratho, outside
Edinburgh to Helen Marshall and Hugh Grainger. Educated at the
University of Edinburgh, at 16 he got a job with John Leslie, a
land surveyor. He started his own practice in 1816, and in 1825 he formed a partnership with
John Miller which lasted until 1847. Their firm operated from the ground floor of Grainger's house at 56 George Street, in the centre of
Edinburgh's New Town. Between 1845 and 1849 his company worked on the digging of the
Bramhope Tunnel and building the
Arthington Viaduct as part of laying the
Leeds to
Stockton-on-Tees line. The first modern
rail ferry, the
Leviathan, was designed in 1849 by Grainger for the
Edinburgh, Perth and Dundee Railway to cross the
Firth of Forth between
Granton and
Burntisland. The service commenced on 3 February 1850. Projects he was involved in included many railway bridges, viaducts and tunnels, including work on the
Monkland and Kirkintilloch Railway,
Ballochney Railway,
Garnkirk and Glasgow Railway,
Wishaw and Coltness Railway,
Paisley and Renfrew Railway,
Dundee and Arbroath Railway,
Arbroath and Forfar Railway, and the
Leeds Northern Railway, where he was chief engineer at the time of his death. He was president of the
Royal Scottish Society of Arts 1849–51, and a fellow of the
Royal Society of Edinburgh 1850.
Benjamin Hall Blyth served as an apprentice under him. He died in
Stockton-on-Tees on 25 July 1852 as a result of injuries sustained in a train collision two days earlier. One of two fatal casualties, Grainger had sustained a compound fracture to his right leg, which quickly turned gangrenous. Following his death his body was returned home for burial in the family plot in the kirkyard at
Gogar. ==Family==