It is better to have it in the locomotive itself. It will be powered by the locomotive directly, and it can be integrated with the system that monitors the locomotive's health. That way, both the locomotive's current working condition and location can be sent to the control center.
When a new loco is attached to the train, they just have to change the train number, for that loco, in the system.
Coaches also get shuffled around during primary maintenance and do not have any data transmission systems built-in. It would be better...
more... to integrate everything into the locomotive.