Can a train be taken from Heathrow or Gatwick to Bath? Or, does one have to go to London first?
No, the only trains from Heathrow airport go into central London. Either the Heathrow Express to Paddington station, or the Piccadilly line to various locations in central London.
But, the good news is that trains to Bath depart from London Paddington station. So, you have two options:
1) Take a connecting coach (express bus) to Reading, and from there a train to Bath.
2) Take the Heathrow Express to London Paddington, ad then another train to Bath.
There are also some direct long-distance buses from Heathrow to Bath, which may or may not be usefully timed for you. Check on www.nationalexpress.com. If you fly into Gatwick, you can get a train from Gatwick Airport station directly to Reading and then change to one for Bath.
We took the bus from Heathrow to Bath and it was perfect. We had to wait a while, but that was good downtime for us. And not having to change trains was good too; we just got on the bus, looked at the countryside, and had a stress-free trip to Bath.
The coach isn't so good if you aren't landing at terminals 2 or 3 convenient for the central bus station. National Express will show services from T5 but they require a change at the central bus station or Bristol.