A Union Pacific train in Dallas. Source: Flickr/Nick Benson.

For decades, the railroads were considered a loser's bet in the investing world. But, oh, how the times have changed.

Since the beginning of 2004, railroad stocks have absolutely crushed the broader market: The industry as a whole delivered a 23.1% average annual return versus the S&P 500's relatively modest 8.3%.

Among the publicly traded American railroads, none outperformed the largest carrier, Union Pacific (NYSE:UNP), during that stretch. This western railroad has proved that connecting the heartland to highly trafficked shipping ports can be a reliably profitable business. And it's one that shows few signs of slowing.

Here are three reasons Union Pacific's stock could continue to outperform.

1. Even the most efficient railroad in America can get better

Source: Flickr/cta web.

Efficiency is of utmost importance in the rail industry, and it's in this category that Union Pacific should continue to set itself apart.

Over the past decade, UP's management team has been hard at work trimming the fat across its rail network in an effort to bolster the bottom line. As a result, the company's operating ratio -- a measure that reflects operating expenses as a percentage of sales -- declined from 87.5% in 2004 to 63.5% today.

This dramatic progress in cost cutting, combined with an average revenue increase of 6.6%, has translated to compounded annual earnings growth of 23% per year since 2004. For an industry that's often constrained by single-digit GDP expansion, that's an impressive performance.

What's more, the company's work is not yet finished. Even during its most efficient quarter to date -- which ended on June 30 -- its performance was far from perfect. Trains were held up because of inclement weather and flooding. Meanwhile, its rival Burlington Northern experienced service delays that translated into excessive volume for Union Pacific. These issues combined to lower rail speeds, which fell 7% versus the prior year. To top it off, train scheduling was suboptimal as operators scrambled to respond to the commotion. Without these abnormal disruptions, it's likely UP could have achieved an even better operating ratio in the quarter.

Nonetheless, management realizes these shortcomings. In the words of CEO Jack Koraleski, Union Pacific is gradually becoming "less reactionary and much more anticipatory" so it can avoid delays. To achieve this goal, the company began installing sensors to embed General Electric's "industrial Internet" throughout its network in 2012. By tracking and responding to data from locomotives, UP has already reduced derailments by 75%, a laudable achievement considering each derailment can cost upwards of $40 million. Expect additional cost savings to be extracted as Union Pacific realizes the full potential of a hyper-connected network.

2. The expansive western terrain provides an edge for rail transport 

Because of escalating fuel prices, railroads have become the preferred mode of transportation for customers who need to move heavy cargo long distances. According to Morningstar, the relative fuel efficiency of railroads allows carriers to charge prices that are 10% to 30% lower than its trucking competitors for moving the same containers.

That's a tremendous competitive advantage, particularly for Union Pacific. Compared with East Coast carriers, Union Pacific and Burlington Northern often transport goods longer distances from ports to populated areas, border crossings, or transfer points. The western expanse of the country in which they operate is flat-out larger than the eastern portion. So where trucks might be able to capture the market for short, quick trips, rail is the obvious choice for their long hauls.

For perspective, this map shows Union Pacific's massive network, which covers 23 states and stretches for 31,800 miles:


Source: Union Pacific.

In addition, this map can reveal a few other important strengths of Union Pacific that will drive growth in the year to come. First off, Union Pacific connects the continental U.S. with Mexico at six different border crossings. Only one other Class I operator, Kansas City Southern, has a single crossing in comparison. That's good news, because Mexico is booming. It will soon eclipse Brazil in terms of auto manufacturing. It stands to benefit from increased energy investment. And, interestingly for beer fanatics, it boasts four out of the top five beers imported to the U.S., an attribute that led to higher volumes for UP in the second-quarter.

Meanwhile, Union Pacific has access to ports all up and down the West Coast. This geographic advantage bodes well for the railroad as trade increases between the two largest economies in the world, the U.S. and China. The latter, in fact, overtook the U.S. as the largest trader of goods in 2013.

3. A diverse business mix makes Union Pacific resilient

Crude oil shipments bolstered railroads' prospects in recent years, but volumes have fallen off thus far in 2014. Source: Flickr/Roy Luck.

Finally, it's important to realize that Union Pacific's broad diversity of businesses is perhaps its single greatest strength.

Geographically speaking, Union Pacific connects U.S. population centers to all four of our biggest trading partners: Canada, Mexico, China, and Japan. No other Class I railroad can claim that.

From a freight perspective, Union Pacific carries cargo that falls into one of six categories: industrial, intermodal, agricultural, coal, chemicals, and autos. Importantly, not one of these categories overwhelms the others in terms of contributing to the top line: Each individually provides more than 10% but less than 20% of revenue.

That matters immensely in a business that can't really stimulate its own demand. And what's most encouraging is that no specific category is expected to significantly drag on future growth. Corn crop production set records last year, which could very well happen again this year. Crude oil extraction is propelling railroad investment. Even coal, which has become less popular for electricity generation in the U.S., is expected to grow faster globally than petroleum or other liquid fuels through 2030.

A sluggish economy could slow down a railroad like Union Pacific, but none of its core businesses seem likely to dampen revenue growth over the long, long haul.

The takeaway for investors

Before buying shares in a railroad, investors want to make sure three critical ingredients are in place: (1) That a smooth-operating management team can drive efficiency gains, (2) that the railroad can outpace GDP growth over the long run, and (3) that it can weather any downturn in demand for a particular commodity or good. With Union Pacific, you can check the box straight down this list. In the years to come, increasing demand for America's natural resources coupled with booming international trade could propel this railroad stock higher.