Yes, however there are a few things to be aware of. First of all you may not always be able to get a signal, as the vehicle you’re in could often be out of range. Secondly, if you’re passing through multiple countries then you need to be careful not to get stung with data charges for countries where you’re not offered free roaming.
Also, there may be a local network on board the plane or boat which your phone might connect to if you allow roaming. This won’t be covered under free roaming and could be expensive – so check the terms and pricing of the network on board before connecting.