Investing in the railroad industry has traditionally been seen as a way to play economic recoveries. But a research note from Standard & Poor’s suggests railroads may be a good bet even in this uncertain economy.

The rail freight business is “less economically sensitive than many believe,” S&P equity analyst Kevin Kirkeby writes in a new research report issued this week.

While rail stocks have been somewhat affected by market turmoil and widespread economic upheaval, they have beaten the market as a whole so far this year, Kirkeby notes. Through Aug. 19, the S&P Railroad sub-industry index was down only 2.8% compared to an 8.6% decline for the S&P 1500 index.

One reason may be that rail freight is broadly diversified across products as diverse as grains, coal, vehicle parts, retail goods and fresh produce. In the second quarter of 2011, railroads posted average revenue growth of 15% as volumes rose nearly 4%. Their average increase in earnings before interest, taxes, depreciation and amortization was 12%.

Meanwhile, earnings per share for the group were up about 21%, and five of the six publicly traded “Class I” railroads exceeded consensus earnings estimates. It may be difficult to keep that up given the wobbly economy, but stock buybacks could give earnings per share a boost, Kirkeby said.

Freight volumes over the next six weeks will be closely watched by rail investors. They are likely to indicate just how much the broader macroeconomic angst and market uncertainties are impacting the railroads and the transportation industry overall.

Morningstar analyst Robert Goldsborough recently noted that rail companies have demonstrated an ability in recent years to begin earning their costs of capital. And he pointed out that Warren Buffett, whose Berkshire Hathaway bought rail giant Burlington Northern Santa Fe a year and a half ago, sees railroads as a way to bet on the U.S. economy over the long term.

So, how do you get railroad exposure?

It’s possible, of course, to invest directly in Norfolk Southern, CSX Corp., Canadian Pacific Railway and others by buying their stock. But S&P points to two transportation-related exchange traded funds with significant railroad components: the S&P Transportation SPDR (XTN) and the iShares Dow Jones Transportation Average Index Fund (IYT).

With 28% of its assets invested in rail stocks as of June 30, IYT had a slightly larger stake in the industry than XTN, which had just 15% of its assets in rail stocks. Three of IYT’s Top 10 holdings were railroads; it’s fairly concentrated, with the Top 10 holdings representing about 72% of total assets. XTN's portfolio was more diversified, holding about 40 stocks.