Who doesn't like taking a train ride? For investors, the rail has been a great place to be over the past few years. But will that continue, and which railroad is best positioned to do well in good times and bad?

Union Pacific (NYSE:UNP) have gained nearly 85% over the past two years, outpacing the S&P 500 by 35 percentage points and the Dow Jones U.S. Railroads Index by 20 percentage points.

Transportation companies, and railroads in particular, are excellent investments during periods of economic growth, providing exposure and leverage to nearly every facet of the economy.

Despite the continued North American economic recovery, U.S. gross domestic product actually contracted during the first quarter. But railroads look set to continue their winning ways. So far this year, Union Pacific stock has gained 18% -- not bad for less than six months of work.

But that's the past, and the question here is whether Union Pacific will deliver market-beating returns over the long haul. Here is the case for, and against, investing in Union Pacific today.

The case for Union Pacific
The term "great franchise" of often used in describing Union Pacific. To me, a great franchise is a company with a sustainable competitive advantage that generates superior revenue and earnings growth -- that's Union Pacific.

Union Pacific is, far and away, the largest railroad in North America. It connects 23 states in the western two-thirds of the country, and transports a diverse mix of goods, including agricultural and industrial products, chemicals, and coal.

Union Pacific has grown revenue and earnings faster than its peers. Over the past five years, revenue grew 4% annually while earning per share spiked16% annually -- the best of all publicly traded Class 1 railroads.

With its expansive network, and as the sole major railroad serving several Midwest and West Coast regions, Union Pacific enjoys unmatched pricing power among U.S. railroads. Union Pacific's profit margin was approximately 20% in 2013, second only to Canadian National (NYSE:CNI) at 24%

Its operating ratio, widely used by railroad companies to assess operational efficiency, is another reason to believe in the strength of Union Pacific as an investment. For 2013, Union Pacific achieved a full-year operating ratio of 66.1% -- a company record and one of the best performances among the major railroads. And it is a near-certainty that the railroad will meet its objective of a sub-65% operating ratio before 2017, further enhancing profitability.

When it comes to returning cash to shareholders, no railroad does better than Union Pacific. Over the past five years, the railroad had a 25% compound annual growth rate on its dividend. It recently raised its dividend by 15% to $0.91 per share; the annualized dividend of $3.64 yields about 1.8%, which is slightly below its peers.

The case against Union Pacific
Building a case against investing in Union Pacific is a challenge, particularly if you are long-term, buy and hold investor. But there are a few areas that investors should consider.

By most valuation measures, Union Pacific trades at a premium to its competitors. In addition, its trailing and forward price-to-earnings ratios are 20% higher today than their five-year averages.

The company is also highly levered to shipping coal, which represents 18% of revenue. Coal revenue has been a problem for the railroad industry over the past few years, with natural-gas prices below historical highs and utility stockpiles higher than normal. With the cold winter and rising natural-gas prices, some utilities have begun switching back to coal. However, the long-term trend for coal use in North America, particularly for U.S. electric power generation, is in decline.

However, it should be noted that Union Pacific transports more coal of the Powder River Basin variety, which should continue to take share from higher-cost Central Appalachian coal for use in the U.S. 

What's a Foolish investor to do?
The case for investing in Union Pacific is strong. Being an outstanding franchise that generates superior revenue and earnings growth, unmatched pricing power, and one of the fastest growing dividends in the industry, will help Union Pacific delivering market-beating returns over the long term.

Justin Lacey has no position in any stocks mentioned. The Motley Fool recommends Canadian National Railway. The Motley Fool owns shares of Canadian National Railway. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.