According to AAP, a 20-year-old Parkdale man was taking a photo of a train with his mobile phone in Hawksburn on Monday night when a train came past and narrowly missed him, a police spokeswoman said.

The driver tried to stop the train but couldn’t before it reached the man, who pressed himself against a fence and managed to avoid being hit by “inches”.

It is not clear if the man was standing on the tracks, or close beside them. The train driver raised the alarm, believing he had hit the man. But it turned out the man managed to press himself against a fence to avoid being struck.

Police have deplored his behaviour, saying people need to take care around trains.

Metro Trains classifies people who venture onto the tracks as trespassers.

Metro spokeswoman Pauline O’Connor said near-misses still occurred far too often.

“Unfortunately, we see people risking their lives around trains, far too often,” Ms O’Connor said.

“In this particular case, our driver thought they had hit the person. The innocent witnesses to people trespassing on train tracks are our drivers.

“Unlike a car, our drivers are not able to swerve the train out of the way, or bring it to a stop quickly.

After a driver applies the emergency break, it can take up to several hundred metres for the train to come to a stop.

“Our drivers are the innocent victims in these incidents and a memory of a near hit can remain with them forever.”

More than 20 train services were affected by Monday’s incident, which led to delays of 15 minutes for commuters on the Frankston, Pakenham and Cranbourne lines, reported The Age.

“We can’t stress enough, how taking risks around trains, is not only dangerous, it can be fatal,” Ms O’Connor said.

Between December 2013 and November 2014, 311 people narrowly avoided death on train tracks.

In the past year, the number of people risking their lives decreased to 236.