As U.S. crude oil production has soared over the past few years, railroad companies have become much larger players in the transport of crude oil.

Over the next several years, however, one major challenge to the continued growth of so-called "crude-by-rail" looms large -- major upcoming pipelines that threaten to snatch away a great deal of market share from rail. Let's take a closer look.

The crude-by-rail boom
Railroads and pipelines both compete in the market for transporting crude oil and other liquids. While pipelines currently move far greater volumes of crude oil than trains, the growth of crude-by-rail has been truly staggering.

According to the Association of American Railroads, U.S. railroads originated a record 108,605 carloads of crude oil in the second quarter of this year, more than double the volume in the same quarter last year. As one would expect, railway companies' profits from their crude-by-rail businesses have grown significantly.

In the second quarter, Union Pacific's (UNP 4.99%) crude oil volumes rose nearly 40% year over year and 3% sequentially, helping deliver a 12% gain in its chemical unit's revenue. A similar story played out at Norfolk Southern (NSC 1.95%), which saw its second-quarter chemicals volume rise 16% year over year. The solid growth was driven primarily by its crude-by-rail business, which saw a whopping 51% sequential increase in shipments during the quarter.

The threat of upcoming pipelines
But over the next several years, three major proposed pipeline projects threaten to take away a great deal of market share from these railroad companies. The first is the controversial northern leg of TransCanada's (TRP 0.50%) proposed Keystone XL pipeline, which would transport up to 830,000 barrels of Canadian and Bakken crude oil per day to Gulf Coast and Midwest refineries.

Another is the proposed expansion of Kinder Morgan Energy Partners' (NYSE: KMP) Trans Mountain Pipeline -- currently the only major pipeline connecting Alberta's oil sands to Canada's West Coast. If the expansion is approved, the line's capacity would more than double to about 750,000 barrels a day by 2017.

And finally, the third major proposed project is Enbridge's (ENB 1.68%) Northern Gateway pipeline, which would ship some 525,000 barrels of oil sands crude from Alberta to the port of Kitimat. If built, these three projects could potentially deliver more than 2 million barrels per day of crude oil to the U.S. Gulf Coast or Canada's West Coast.

Pipelines facing harsh opposition
But as it stands, it's unclear whether any, let alone all three, of these projects will be built. Enbridge's proposed Northern Gateway pipeline faces heavy opposition from environmentalists and even the government of British Columbia. The project is currently being reviewed by a federal joint review panel, which will issue a recommendation by the end of the year.  

Similarly, Kinder Morgan's Trans Mountain expansion, for which the company recently filed a project description with the National Energy Board though not yet a regulatory application, also faces opposition from environmentalists and Canadian First Nations groups, who are concerned about potential oil spills in Vancouver Harbor.

And then there's Keystone XL, perhaps the most contentious of the three projects. In addition to opposition from environmentalists and climate change campaigners, several influential figures, including California billionaire Tom Steyer, continue to lead the charge against its approval. As it stands, the State Department is working on an environmental impact statement for the line, which is likely to be finalized and submitted sometime this year.

The bottom line
All told, the combined impact of having all these pipelines approved, built, and put into service would probably be severe for rail companies' chemicals transport businesses. But at this point, it's still highly uncertain whether any or all of them will be approved.

On the flip side, if even one of these projects is rejected, especially Keystone, it would almost certainly be viewed as a major win for rail companies. According  to estimates by RBC Capital Markets, Canadian crude rail shipments would grow by an additional 42% by 2017 without Keystone XL.