I prefer traveling by train over flying.

Literal

I [topic-は], airplane [than-より] train [by-で] travel [object-を] do direction [subject-が] like.

で here is instrumental — 'by means of train.' The preference pattern Aより Bの方が好き is embedded around the nominalized clause 電車で旅をする ('traveling by train'). 旅をする is a light-verb use of 旅 ('trip, journey') — more evocative than 旅行する.