Two years ago, Canadian National Railway (CNI -5.05%) was shipping approximately zero railcars full of oil or petroleum products. Those days are long gone, however, and through the first nine months of this year, petroleum and chemicals shipments accounted for 16% of the company's revenue. It's quite the turnaround, and highlights just how important oil has become to railroads.

Riding the rails
Over the last year, oil has made itself at home on North American freight trains, and crude shipments have increased by about 360,000 barrels per day. According to the Association of American Railroads, petroleum and petroleum product shipments reached 20,906 carloads in October, a 54.5% increase year over year.

Canadian National isn't the only winner, obviously. American railroad giant Union Pacific (UNP -1.82%) is doing its part, too. The company experienced a 15% pop in third-quarter earnings because of price increases and an uptick in shipments of petroleum products and automobiles.

Union Pacific is happily experiencing the effects of America's oil and gas boom from all angles, shipping necessary materials to drilling sites, and then turning around and carting oil back out to markets. The company's petroleum products shipments increased 95% in the third quarter.

Oil wins, too
As it turns out, railroads are just as important to oil as oil has become to railroads. Producers would be struggling big time if it wasn't for access to railcars and terminals. Though millions of miles of pipeline crisscross our nation, they are highly concentrated in regions that have historically generated much of this nation's oil production. There are not, for example, pipelines all over North Dakota in the same way that they are all over Texas. What North Dakota does have, however, are railroads.

Continental Resources (CLR), the largest leaseholder in North Dakota's Bakken Shale, is shipping 65% of its oil out of the play via rail. That's over 40,000 barrels per day! Without question, Continental has been saved by rail in the short term. The company's CFO, John Hart, credits rail for solving the immediate needs of oil producers in the Bakken by allowing them to reach previously unreachable markets on the West and East Coasts, but maintains that there is still a need for pipelines in the region.

Few would argue that point, as oil production in the Bakken is expected to climb from over 600,000 barrels per day right now, to potentially more than 1.5-million barrels per day in the coming years. Current pipeline capacity in the region is tight, and while additional capacity is expected to come online between the end of this year and next, it is not ready yet, and rail is expected to be a meaningful alternative in the near-term.

Fear of commitment
There is a chance that rail will continue to be the transport of choice among some oil producers even if pipeline capacity ramps up in the Bakken. During a conference call regarding its third-quarter earnings, Plains All American (PAA 1.11%) CEO Greg Armstrong agreed that the preferred method of oil transport is via pipeline, but he also raised a valid point about the benefits of shipping via rail cars.

The economics of the Bakken, combined with its distance from markets, make producers wary of signing 10-year shipping contracts with pipeline companies; bearing in mind it takes years to bring pipeline projects to fruition. Therefore railroads, according to Armstrong, will remain crucial to Bakken producers, perhaps more so than the other American oil plays.

After all, transportation via rail does not require long-term commitments. Rail shipments are also able to reach markets faster than pumping crude through a pipeline. Despite higher costs, there is greater flexibility shipping via rail right now, and it is an advantage that may not erode as quickly as some think.

One thing that really stands out about Plains All American is the variety of transportation assets the company possesses. Plains operates not just pipelines, but trucks, trains, and barges as well. The partnership plans to have 6,000 railcars in service by the end of next year, shipping oil and natural gas liquids all over the country. It is definitely a company worth considering given the state of the American energy scene right now.

Foolish takeaway
The growth in American energy production presents a variety of ways for investors to cash in. Obviously producers like Continental Resources benefit, but so do railroads and midstream companies that are positioned to take advantage.