I do see the auditor types hassling railway staff on a regular basis, I would generally like to avoid that approach
We got the no fly zones and they mostly apply to zones around the airports and prisons and whatnot. the second rule you are quoting only applies to older drones that are over 250 grams, under 250g or the new c1 class can be flown anywhere even over "uninvolved people" but obviously such things are discouraged unless nessesary.
It more becomes a question of, if im flying lawfully in a field or such a place that there is a line running through with the intention of filming the train as it passes and possibly even following it for a short distance as part of the video. Can i actually do this since realistically I am flying adjacent to the railway and not above it.
that being said should the driver or someone see a drone following his train briefly, will they actually care or have to report it to someone or anything like that?
Another thing which can be done with a drone nowadays is the construction of an accurate 3d model of a building from a series of photographs of said building, such an application could prove very handy for us model makers but assumedly most of these buildings would be based on the railway and overflight would be required in order to capture all of the required data and thats where you might be asking for trouble.