Public railroad stocks can be especially attractive in a growth economy. Few industries are as closely tied to economic growth as those involved in moving goods and commodities. Railroad stocks took a beating in the past few years, due in part to the falling fortunes of coal, which accounts for nearly 40% of America's railroad tonnage. Declining oil and gas production, as well as the increasing use of pipelines over railways, also hurt the industry. (See also: A Primer on the Railroad Industry.)

However, depressed prices may provide an opportunity for value investors to enter this space, taking their cues from Warren Buffett and even Bill Gates, both of whom are heavily invested in railroads. Buffett's Berkshire Hathaway acquired Burlington Northern Santa Fe in 2009, and Gates holds a significant stake in Canadian National Railway Company.

Railroads transport the vast majority of all major industrial and consumer goods, so railroad companies are very sensitive to movements in the economy. A growing economy could point to growth in public railroad stocks. If you're looking for exposure to this sector, here are three of the largest railroad stocks in 2017.

Note: All figures are as of November 2, 2017.

Union Pacific Corporation (UNP)

This is the granddaddy of American railways, established in 1862, with a market cap of $92 billion. It is the supply chain link for much of the western United States, connecting approximately two-thirds of the country – and some 20 states – by rail. It operates roughly 9,000 locomotives and connects the Canadian rail lines with the Gulf of Mexico. Its rail network covers around 32,000 miles.

Union Pacific has reported revenue of $20.96 billion over the last twelve months and has earnings per share of $5.65. It currently trades at $117.27, up 15.94% over the past year. The stock is trading below its 12-month price target of $123.11 and has a 52-week range of $87.88 to $119.71. (See also: Norfolk Southern a Better Buy Than Union Pacific.)

Canadian National Railway Company (CNI)

Canadian National has a market cap of $59.64 billion. Although it's technically a Canadian railway, it operates 20,000 miles of track across the U.S. and Canada, connecting the Atlantic and Pacific oceans and the Gulf of Mexico. It moves freight for several major commodities groups – including oil, liquid natural gas and chemicals – and it has access to all the NAFTA countries.

The company has trailing twelve month revenue of $10.13 billion and earnings per share of $3.98. It currently trades at $80.37 with a 52-week range of $61.72 to $84.48. The stock has a one-year price target of $84.62. It is currently up 30.92% over the past 12 months. (See also: This Is What Bill Gates' Portfolio Looks Like.)

CSX Corporation (CSX)

CSX has a market cap of $46 billion and gross revenue of $11.58 billion over the past twelve months. The Florida-based company operates mainly on the east coast and is the third largest Class I railroad. The company operates in three main areas – merchandise, intermodal and coal – and it handles domestic coal shipments to power plants as well as exports to deep-water port facilities. Its merchandise line transports food, agricultural, automotive and forest products, among other goods.

CSX currently trades at $51.45 with a 52-week trading range of $30.92 to $55.48. The stock has a price target of $58.46. It has gained 70.40% over the past year. (See also: CSX Earnings Could Wake Up Sleepy Transports.)

Want to learn how to invest?

Get a free 10 week email series that will teach you how to start investing.

Delivered twice a week, straight to your inbox.