Crude by rail has been a huge growth segment for Canadian National Railway Company (TSX:CNR)(NYSE:CNI) over the past several years—in 2012, CN moved about 34,000 carloads of crude. Last year this number was 128,000.

Recently, however, reductions in production combined with increased pipeline capacity have meant that crude by rail is falling out of favour. The Alberta Clipper pipeline was expanded by 230,000 b/d to bring crude into the U.S., and a combination of the Flanagan South pipeline and Seaway pipeline have added huge amounts of capacity to the Gulf Coast.

Not only does this provide producers with more access to Gulf Coast and Midwest refineries, but it also comes at (sometimes) less than half the price of rail. Fortunately for CN, it appears some of the factors that initially drove the increase in crude by rail are returning, which could mean crude by rail is poised for strength.

Pipeline capacity is tightening once again and spreads may increase

One of the most important factors driving crude by rail is the spread between the price of Western Canadian Select (WCS), which is Canadian heavy crude, and the price of West Texas Intermediate Crude (WTI), or Mexican Maya Crude.

Mexican Maya crude is extremely similar in quality to WCS, with the only difference being that it has easy access to tidewater and as a result enjoys a better price. When the spread between WCS and WTI is high, it is worthwhile for producers to pay the $12-20 per barrel it costs to ship oil by rail to the Gulf Coast.

Recently, spreads have been declining thanks to better pipeline and rail capacity, but many think that spreads may strengthen once again. Cenovus Energy’s CEO recently stated that thanks to increasing production coming online soon in Alberta and the fact that there’s no new pipeline capacity coming online in the near term, spreads should increase once again.

He stated that rail economics would improve in this environment and as a result rail movements would increase perhaps significantly over the next several years. CN would be poised to benefit from this as they have direct access to the oil sands as well as a large network that connects to many refining regions that producers could use if pipelines are not available.

Just how much will pipeline capacity tighten? The Canadian Association of Petroleum Producers (CAPP) sees oil sands production growing by nearly one million barrels per day from now until 2020. Unfortunately, with Keystone XL recently rejected, there is very little capacity slated to come online to meet this demand, leaving plenty of room for rail.

Enbridge Inc.’s Northern Gateway pipeline is slated to bring 525,000 b/d to the west coast, but a recent crude oil tanker ban by the new Canadian government means that there is very little chance that Northern Gateway could actually go through. Kinder Morgan’s Trans Mountain pipeline expansion is still in play, since it would terminate in an area where the tanker ban does not apply, but the fate of this pipeline is unknown as well.

This means the only certain expansion coming online to handle all this extra crude is Enbridge’s Line 3 Restoration, which will bring online about 400,000 b/d of capacity in 2017; it won’t be enough to cover the new production coming online.

CN Rail could be poised to benefit

This means that the next five years could be an excellent time for the crude-by-rail business. Production is increasing, and even if the Trans Mountain pipeline does go through, it would not be in operation until the beginning of 2019, which means that rail could see a boost for the next few years.

CAPP estimated in their recent outlook that if Keystone XL were rejected, total crude-by-rail volumes could be 500,000-600,000 b/d by 2018. In 2014, 185,000 b/d of western Canadian oil was transported to market by rail. CN would almost certainly be capturing some of this growth.

In addition to this, CN is the only Canadian railway that has direct access to the Gulf Coast, which is a huge market for Canadian heavy oil because many of the refineries there are outfitted to process heavy crude specifically.

Investors can't go wrong with rail stocks, but our analysts have identified an even better way to play rising crude production

Fortunately, you can download the name, ticker symbol, and price guidance absolutely FREE.

Simply click here to receive your Special FREE Report, "1 Top Stock for 2015--and Beyond."

NEW! This Stock Could Be Like Buying Amazon In 1997

For only the 5th time in over 14 years, Motley Fool co-founder David Gardner just issued a Buy Recommendation on this recent Canadian IPO.

Stock Advisor Canada’s Chief Investment Adviser, Iain Butler, also recommended this company back in March – and it’s already up a whopping 57%!

Enter your email address below to claim your copy of this brand new report, “Breakthrough IPO Receives Rare Endorsement.”

Fool contributor Adam Mancini has no position in any stocks mentioned. David Gardner owns shares of Canadian National Railway. The Motley Fool owns shares of Canadian National Railway and Kinder Morgan. Canadian National Railway is a recommendation of Stock Advisor Canada.